Hi,
I am very new to Rails. I am starting my learning process by first listing all the users.
FIrst i had added a action in the controller as
def list_users
@users=User.find(:all)
end
And in the View users/list_users.html.erb
i have added the line
list_users.html.erb
:
<%= Time.now %>
<% @users.each do |user| %>
<%= user.firstname %>
<% end %>
And for routing i have added the routes as
map.list_users '/list_users', :controller => 'users', :action => 'list_users'
Thats it .. when i run my app , its showing me the error as
Development mode eh? Here is the error - #<ActionView::TemplateError:
ActionView::TemplateError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each) on line #7 of app/views/users/list_users.html.erb:
Why so ?? Please give some suggestions ..
Solution :
I myself find that the controller action is under protected , thats why it showed me the error. Sorry for asking silly question THanks for everyone 's help .