This works fine:
<% blog.articles.each_with_index do |article, i| %>
<h2><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></h2>
<%= article.body %>
<% end %>
This does not:
<% blog.articles.each_with_index do |article, i| %>
<h2><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></h2>
<%= article.summary %>
<% end %>
Something about that summary throws an error:
TypeError: type mismatch: String given
/Users/bob/.rvm/gems/ruby-2.3.0/gems/middleman-blog-4.0.0/lib/middleman-blog/blog_article.rb:110:in `=~'
/Users/bob/.rvm/gems/ruby-2.3.0/gems/middleman-blog-4.0.0/lib/middleman-blog/blog_article.rb:110:in `default_summary_generator'
/Users/bob/.rvm/gems/ruby-2.3.0/gems/middleman-blog-4.0.0/lib/middleman-blog/blog_article.rb:98:in `summary'
/Users/bob/Dropbox/Web Development/Projects/Middleman/BRP/source/index.html.erb:11:in `block (2 levels) in singleton class'
and so on...
Here's the part of my config.rb concerning the blog gem:
activate :blog do |blog|
# This will add a prefix to all links, template references and source paths
# blog.prefix = "blog"
# blog.permalink = "{year}/{month}/{day}/{title}.html"
# Matcher for blog source files
blog.sources = "posts/{year}-{month}-{day}-{title}.html"
# blog.taglink = "tags/{tag}.html"
# blog.layout = "layout"
blog.summary_separator = "==="
blog.summary_length = 250
# blog.year_link = "{year}.html"
# blog.month_link = "{year}/{month}.html"
# blog.day_link = "{year}/{month}/{day}.html"
# blog.default_extension = ".markdown"
blog.tag_template = "tag.html"
blog.calendar_template = "calendar.html"
# Enable pagination
blog.paginate = true
blog.per_page = 10
blog.page_link = "page/{num}"
end
# activate :directory_indexes
And my gemfile:
```
source 'http://rubygems.org'
Middleman Gems
gem "middleman", "~> 4.1.0"
gem "middleman-blog"
gem "middleman-livereload"
gem 'middleman-autoprefixer'
gem 'redcarpet', '~> 3.3', '>= 3.3.3'
For feed.xml.builder
gem "builder", "~> 3.0"
```
Where have I gone wrong?
Just a hunch, but blog.summary_separator = "===" looks like a troublemaker.
Try another string that couldn't be incorrectly interpreted as a comparison operator and see if it works.
Maybe try blog.summary_separator = /(READMORE)/
Don't forget to make that change in your post files as well. (Forgetting that sort of stuff is what makes me chase my tail more often than not.)
You don't really need to uncomment the two lines in config.rb:
blog.summary_separator = "==="
blog.summary_length = 250
Try adding this line below
<%= article.summary %>
<%= link_to 'Read more…', article %>
Related
Hey here! I'm kinda new to Rails and I've been trying to find some answers but no luck yet so here we go.
I've set up a basic Rails app and just trying to save a Client to my database with a validation but nothing seems to be coming together. Anyone could point me to the right direction please or let me know what I've been doing wrong in my code.
I keep getting errors like this:
NoMethodError in Clients#new
Showing /Users/******/Documents/******/*****/app/views/clients/_form.html.erb where line #1 raised:
undefined method `clients_path' for #<ActionView::Base:0x00000000064a50>
Did you mean? clients_new_path
Even if I remove #client = Client.new from the new method I can view the page but nothing gets saved.
I'm stuck really now so any help much appreciated!
Thanks!
My Routes.rb file:
Rails.application.routes.draw do
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
get 'dashboard/index'
root to: "home#index"
devise_for :users, controllers: {
sessions: 'users/sessions',
passwords: 'users/passwords',
registrations: 'users/registrations'
}
get '/clients/index'
get '/clients/new'
get '/clients/edit'
get '/clients/delete'
get '/clients/:id', to: 'clients#show'
post '/clients/new', to: 'clients#create'
end
My Dashboard file:
<% if user_signed_in? %>
<nav class="subnav">
<ul>
<li><%= link_to('My Clients', clients_index_path) %></li>
<li><%= link_to('Add Client', clients_new_path) %></li>
<li><%= link_to('Edit registration', edit_user_registration_path) %></li>
<li><%= link_to('Logout', destroy_user_session_path, :method => :delete) %></li>
</ul>
</nav>
<% else %>
<%= link_to('Register', new_user_registration_path) %>
<%= link_to('Login', new_user_session_path) %>
<% end %>
My ClientsController file:
class ClientsController < ApplicationController
def index
#clients = Client.all
end
def new
#client = Client.new
end
def show
#client = Client.find(params[:id])
end
def create
#client = Client.new(client_params)
if #client.save
redirect_to #client
else
render :new
end
end
def edit
end
def delete
end
private
def client_params
params.require(:client).permit(:name, :provider)
end
end
My form:
<%= form_with model: #client do |form| %>
<div>
<%= form.label :name %><br>
<%= form.text_field :name %>
<% client.errors.full_messages_for(:name).each do |message| %>
<div><%= message %></div>
<% end %>
</div>
<div>
<%= form.label :provider %><br>
<%= form.text_field :provider %>
</div>
<div>
<%= form.label :business_type %><br>
<%= form.select :business_type, ["Partnership", "Sole Trader", "Limited Company"] %>
</div>
<div>
<%= form.submit %>
</div>
<% end %>
Finally my new.html.erb file:
<h1>Clients#new</h1>
<%= render 'form', client: #client %>
clients_path is generated by resources :clients, only: :index or you probably need to give your route the name you want. Try this
get '/clients/index', as: :clients
or, if you want to specify non default paths as you're doing, your index is probably called clients_index_path, but you can check that with a rake routes or rails routes, because I'm not sure.
That said, I suggest you to go with the resources method in your routes file and use the default paths as you're trying to do. Something like
resources :clients
but now you don't have a path like /clients/index no more, just /clients for the index action.
If you're in doubts with routes try to read the guide about routing
The Rails way to declare the routes to Create, Update, Read and Destroy (CRUD) a resource is just:
Rails.application.routes.draw do
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
get 'dashboard/index'
root to: "home#index"
devise_for :users, controllers: {
sessions: 'users/sessions',
passwords: 'users/passwords',
registrations: 'users/registrations'
}
resources :clients
end
As you can see by the annotions above each method Rails does not add the "action" to the path except for the new and edit routes:
class ClientsController < ApplicationController
before_action :set_client, only: [:show, :edit, :update, :destroy]
# GET /clients
def index
#clients = Client.all
end
# GET /clients/1
def show
end
# GET /clients/new
def new
#client = Client.new
end
# POST /clients
def create
#client = Client.new(client_params)
if #client.save
redirect_to #client
else
render :new
end
end
# GET /clients/edit
def edit
end
# PATCH /clients/1
def update
if #client.update(client_params)
redirect_to #client
else
render :edit
end
end
# DELETE /clients/1
def delete
#client.destroy
redirect_to action: :index,
notice: 'Client deleted'
end
private
def set_client
#client = Client.find(params[:id])
end
def client_params
params.require(:client).permit(:name, :provider)
end
end
Thus you don't create resources with post '/clients/new' - You use POST /clients. Also when you use the "bare-bones" routing methods such as match, get, post etc Rails does not automatically add routing helper. If you actually wanted to generate the equivilent routes you would need to use:
post '/clients',
to: 'clients#create',
as: :clients
But you're much better off embracing the conventions and learning to use them to be productive.
I have two Actioncable channels setup(chatroom_channel and comment_channel). Comment channel isnt working.
The comment is being created and when I manually refresh the page the comment renders. However, the comment is supposed to render without manually pressing the refresh button from the browser.
This is the console output from the one that is working:
Started POST "/messages" for 127.0.0.1 at 2020-07-15 12:54:31 -0400
Processing by MessagesController#create as JS
Parameters: {"message"=>{"content"=>"hello"}, "commit"=>"Send"}
Chef Load (0.1ms) SELECT "chefs".* FROM "chefs" WHERE "chefs"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:11:in `current_chef'
(0.1ms) begin transaction
↳ app/controllers/messages_controller.rb:7:in `create'
Message Create (0.3ms) INSERT INTO "messages" ("content", "chef_id", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["content", "hello"], ["chef_id", 1], ["created_at", "2020-07-15 16:54:31.377225"], ["updated_at", "2020-07-15 16:54:31.377225"]]
↳ app/controllers/messages_controller.rb:7:in `create'
(62.6ms) commit transaction
↳ app/controllers/messages_controller.rb:7:in `create'
Rendered messages/_message.html.erb (Duration: 0.7ms | Allocations: 247)
[ActionCable] Broadcasting to chatroom: {:message=>"<div class=\"message\">\n <p>\n <small><em>Created less than a minute ago</em></small>\n </p>\n <p>\n <img alt=\"john\" class=\"rounded-circle\" src=\"https://secure.gravatar.com/avatar/1c9e974c08914cda5ca2e7620c4fd3b6?s=50\" />\n <strong>John </strong>\n <span class=\"content\">\n hello\n </span>\n </p>\n</div>", :chef=>"john"}
Completed 200 OK in 82ms (Views: 13.3ms | ActiveRecord: 63.1ms | Allocations: 5133)
ChatroomChannel transmitting {"message"=>"<div class=\"message\">\n <p>\n <small><em>Created less than a minute ago</em></small>\n </p>\n <p>\n <img alt=\"john\" class=\"rounded-circle\" src=\"https://secure.gravatar.com/avatar/1c9e974c08914cda5ca2e7620c4fd3b6?s=50\" />\n <strong>John </strong>\... (via streamed from chatroom)
This is the console output from the one that is not working:
Started POST "/recipes/11/comments" for 127.0.0.1 at 2020-07-15 12:53:49 -0400
Processing by CommentsController#create as JS
Parameters: {"comment"=>{"description"=>"test comment"}, "commit"=>"Submit Comment", "recipe_id"=>"11"}
Chef Load (0.2ms) SELECT "chefs".* FROM "chefs" WHERE "chefs"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:11:in `current_chef'
Recipe Load (0.2ms) SELECT "recipes".* FROM "recipes" WHERE "recipes"."id" = ? ORDER BY "recipes"."updated_at" DESC LIMIT ? [["id", 11], ["LIMIT", 1]]
↳ app/controllers/comments_controller.rb:6:in `create'
(0.1ms) begin transaction
↳ app/controllers/comments_controller.rb:9:in `create'
Comment Create (0.3ms) INSERT INTO "comments" ("description", "chef_id", "recipe_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["description", "test comment"], ["chef_id", 1], ["recipe_id", 11], ["created_at", "2020-07-15 16:53:49.203129"], ["updated_at", "2020-07-15 16:53:49.203129"]]
↳ app/controllers/comments_controller.rb:9:in `create'
(50.3ms) commit transaction
↳ app/controllers/comments_controller.rb:9:in `create'
Rendered comments/_comment.html.erb (Duration: 1.7ms | Allocations: 1480)
[ActionCable] Broadcasting to comments: "<div class=\"row\">\n <div class=\"col-md-2\">\n <section class= \"chef_info center\">\n <img alt=\"john\" class=\"rounded-circle\" src=\"https://secure.gravatar.com/avatar/1c9e974c08914cda5ca2e7620c4fd3b6?s=60\" />\n </section> \n </div>\n\n <div class=\"comment col-md-8 card bg-light\">\n <p>test comment</p>\n <p class=\"quiet small\">Created: less than a minute ago by john</p>\n </div>\n</div>"
Completed 200 OK in 121ms (Views: 4.4ms | ActiveRecord: 52.0ms | Allocations: 23379)
The main difference is the last line ChatroomChannel transmitting while the other one doesnt have the equivelant. It seems the CommentChannel isn't transmitting after it has been created?
app/channels/application_cable/connection.rb:
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_chef
def connect
self.current_chef = find_current_user
end
def disconnect
end
protected
def find_current_user
if current_chef = Chef.find_by(id: cookies.signed[:chef_id])
current_chef
else
reject_unauthorized_connection
end
end
end
end
app/channels/comments_channel.rb
class CommentsChannel < ApplicationCable::Channel
def subscribed
# stream_from "some_channel"
stream_from "comments"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
end
app/controllers/comments_controller.rb
class CommentsController < ApplicationController
#ensure current chef is available
before_action :require_user
def create
#recipe = Recipe.find(params[:recipe_id])
#comment = #recipe.comments.build(comment_params)
#comment.chef = current_chef
if #comment.save
ActionCable.server.broadcast "comments", render(partial: 'comments/comment', object: #comment)
#flash[:success] = "Comment was created successfully"
#redirect_to recipe_path(#recipe)
else
flash[:danger] = "Comment was not created"
redirect_back(fallback_location: root_path)
end
end
private
def comment_params
params.require(:comment).permit(:description)
end
end
app/javascript/comments_channel.js
import consumer from "./consumer"
consumer.subscriptions.create("CommentsChannel", {
connected() {
// Called when the subscription is ready for use on the server
},
disconnected() {
// Called when the subscription has been terminated by the server
},
received(data) {
// Called when there's incoming data on the websocket for this channel
return $("#messages").prepend(data);
}
});
app/views/recipes/show.html.erb:
<%= render "shared/page_title", title: #recipe.name %>
<div class="col-md-8 offset-md-2 card card-body bg-light">
<h4 class="center description"><strong>Steps: </strong></h4>
<hr/>
<%= simple_format(#recipe.description) %>
<hr/>
<% if #recipe.ingredients.any? %>
<p>Ingredients: <%= render #recipe.ingredients %> </p>
<% end %>
<div class="ml-auto">
<p class="center">
<em>Created by:</em>
</p>
<p class="center">
<%= link_to gravatar_for(#recipe.chef), chef_path(#recipe.chef) %>
</p>
<p class="center">
<small><%= #recipe.chef.chefname.capitalize %></small>
<div class="ml-auto"><%= time_ago_in_words(#recipe.created_at) %> ago</div>
</p>
</div>
<div class="recipe-actions">
<% if logged_in? && (current_chef == #recipe.chef || current_chef.admin?) %>
<%= link_to "Edit this recipe", edit_recipe_path(#recipe), class: "btn btn-xs btn-warning" %>
<%= link_to "Delete this recipe", recipe_path(#recipe), method: :delete,
data: {confirm: "Are you sure you want to delete this recipe?"}, class: "btn -btn-xs btn-danger" %>
<% end %>
<%= link_to "Return to recipes listing", recipes_path, class: "btn btn-xs btn-primary" %>
</div>
<%# add likes glyph icons here %>
</div>
<%# add nested route for comment %>
<% if logged_in? %>
<div class="row">
<div class="col-md-8 offset-md-2">
<h3>Comments: </h3>
<hr />
<%= form_for([#recipe, #comment], remote: true, :html => {class: "form-horizontal", role: "form"}) do |f| %>
<div class="row form-group">
<%= f.label :Comment, :class => 'control-label col-md-2' %>
<div class="col-md-8">
<%= f.text_area :description, rows: 8, class: "form-control", placeholder:"Enter comment here" %>
</div>
</div>
<div class="row form-group">
<div class="col-md-8 offset-md-2">
<%= f.submit "Submit Comment", class: "btn btn-primary btn-lg btn-xlarge" %>
</div>
</div>
<% end %>
<hr />
</div>
</div>
<% end %>
<%# if there are comments for this recipe, display them at the bottom %>
<% if #recipe.comments != 0 %>
<div class="row">
<div class = "col-md-8 offset-md-2">
<h3>Prior Comments: </h3>
<div id="messages">
<%= render partial: 'comments/comments', object: #comments %>
</div>
</div>
</div>
<% else %>
<div class="row">
<div class="col-md-8 offset-md-2">
<h3> No comments yet! </h3>
</div>
</div>
<% end %>
gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.6'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3'
# Use sqlite3 as the database for Active Record
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
gem 'bootstrap-sass', '~> 3.4.1'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
gem 'bcrypt', '~> 3.1.7'
#add pagination to the site
gem 'will_paginate', '3.1.7'
#gem 'bootstrap-will_paginate', '~> 1.0'
gem 'will_paginate-bootstrap4'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false
group :development, :test do
gem 'sqlite3', '~> 1.4'
gem 'rails-controller-testing'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
end
group :production do
gem 'pg'
gem 'redis'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
I created a rails app, added a top menu bar with position fixed. It works fine in development but when I deploy it online, I can't see my menu bar. Also I added glyph icons using FontAwesome but it doesn't show that either.
My production.rb
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.serve_static_assets = true
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
config.assets.compile = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
My application.html.haml
!!!
%html
%head
%title Blogger
= stylesheet_link_tag 'application', media: 'all'
= javascript_include_tag 'application'
%link{:rel => "stylesheet", :href => "http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css"}
%link{:rel => "stylesheet", :href => "http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"}
= csrf_meta_tags
%body
%header
.wrapper.clearfix
#logo= link_to "Blogger", root_path
%nav
- if user_signed_in?
= link_to current_user.name, edit_user_registration_path
= link_to "Logout", destroy_user_session_path, :method => :delete
= link_to "Add New Post", new_post_path, class: "button"
- else
= link_to "Sign in", new_user_session_path
= link_to "Sign Up", new_user_registration_path
= link_to t('Contact'), new_contact_path
%p.notice= notice
%p.alert= alert
= yield
To be specific, it doesn't load anything under the %header
I'm trying to build a very basic Rails app for posting images with a comment. The comment is a required field and the image upload should only go ahead if the comments section has a value, displaying an error message otherwise.
The problem I am having is that even when the comments section is filled in it still displays an error saying that it cannot be blank.
I have tried adding attr_accessor's with the html field names and database values but it makes no difference.
Posts model
class Post < ActiveRecord::Base
has_attached_file :picture, styles: { medium: "300x300>", thumb: "100x100>" }
attr_accessor :picture_file_name
attr_accessor :post_description
validates :description, presence: true
end
Posts controller
class PostsController < ApplicationController
def index
#posts = Post.all
end
def new
#post = Post.new
end
def create
#post = Post.new params[:post].permit(:description, :picture)
if #post.save
redirect_to '/posts'
else
render 'new'
end
end
end
new.html.erb
<% if #post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(#post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% #post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= form_for #post, :html => { :multipart => true } do |f| %>
<%= f.label :description %>
<%= f.text_area :description %>
<%= f.label :picture %>
<%= f.file_field :picture %>
<%= f.submit %>
<% end %>
Server readout
=> Booting WEBrick
=> Rails 4.0.4 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-04-20 17:59:07] INFO WEBrick 1.3.1
[2014-04-20 17:59:07] INFO ruby 2.1.0 (2013-12-25) [x86_64-darwin12.0]
[2014-04-20 17:59:07] INFO WEBrick::HTTPServer#start: pid=98772 port=3000
Started POST "/posts" for 127.0.0.1 at 2014-04-20 17:59:21 +0100
ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by PostsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"nVrCEAdT+epbltQWR74jtv1weGaq6H7YbWQKFfJNDTw=", "post"=>{"description"=>"test comment", "picture"=>#<ActionDispatch::Http::UploadedFile:0x0000010242f740 #tempfile=#<Tempfile:/var/folders/lm/vrw53rx91831vrh4228m0mfw0000gn/T/RackMultipart20140420-98772-1c9msrz>, #original_filename="dory_2.jpg", #content_type="image/jpeg", #headers="Content-Disposition: form-data; name=\"post[picture]\"; filename=\"dory_2.jpg\"\r\nContent-Type: image/jpeg\r\n">}, "commit"=>"Create Post"}
WARNING: Can't mass-assign protected attributes for Post: description, picture
app/controllers/posts_controller.rb:12:in `create'
(0.1ms) begin transaction
(0.1ms) rollback transaction
Rendered posts/new.html.erb within layouts/application (13.1ms)
Completed 200 OK in 105ms (Views: 65.6ms | ActiveRecord: 0.4ms)
Your params & form look okay
But I would change your strong params to be more conventional:
def create
#post = Post.new(post_params)
#post.save
end
private
def post_params
params.require(:post).permit(:description, :picture)
end
I found the problem.
The issue was that I had originally installed the latest version of Paperclip and then downgraded.
I had added the following gem while I was searching for a solution
gem 'protected_attributes'
This was causing all required fields not to register they were being filled in, such as in user sign up fields etc.
Once that gem was removed it worked just fine.
Not sure what's wrong. I've tried removing the space between the < and % but the app wouldn't run.
< % if logged_in? %>
Welcome < %= current_user.username %>! Not you?
< %= link_to "Log out", logout_path %>
< % else %>
< %= link_to "Sign up", signup_path %> or
< %= link_to "log in", login_path %>.
< % end %>
The error I get is:
NoMethodError in Posts#index undefined method `logged_in?' for #<#<Class:0x00000101ab0250>:0x00000101aab0c0>
Did you mean :
<% if current_user.logged_in? %>
Your current piece of code will try to use the logged_in? helper wich i guess is not what you want.
If you are using the "restful_authentication", trying adding include AuthenticatedSystem like below
#app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
include AuthenticatedSystem
.....
logged_in? is a protected method inside the AuthenticatedSystem module
module AuthenticatedSystem
protected
# Returns true or false if the <%= file_name %> is logged in.
# Preloads #current_<%= file_name %> with the <%= file_name %> model if they're logged in.
def logged_in?
!!current_<%= file_name %>
end
......
HTH