Okay, I know this is a really beginner question. But....
I created a migration to create an entity post. I gave it a title. I
ran the migration.
Then, I created an admin controller, entitled simply admin_controller.
I defined an index action like so:
def index
@posts=Post.find(:all)
end
Then I created an index view:
<% @posts.each do |post| %>
<%=post.title%>
<%end%>
What do I get?
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
So I created a migration to add a row to the database so there would
be at least one. Still get the nill object. What's going on? What
really basic thing have I overlooked?
Thanks for looking at it...I thought it looked okay. How would I find
out if the code was being executed? I'm just using the default
routing configuration, so if I type http://localhost:3000/admin/index
that should call up the controller code, no?
Well, so I created a separate pages controller. It works from the
pages controller.
localhost:3000/pages/
pages might be a magic name (given that there is an actioncontroller
module of the same name to do with page caching). By having a
controller there you might be messing things up.