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? Ron --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 11 Mar 2008, at 15:37, Ron wrote:> > 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 >Hi Ron, That looks ok. Are you sure the code in your action is getting executed ? Fred> 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? > > Ron > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Fred, 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? Thanks, Ron On Mar 11, 8:43 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 11 Mar 2008, at 15:37, Ron wrote: > > > > > > > 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 > > Hi Ron, > > That looks ok. Are you sure the code in your action is getting > executed ? > > Fred > > > 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? > > > Ron--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hmm...I just restarted my webbrick server and it worked. That''s strange. I thought you didn''t have to restart the server for new actions. On Mar 11, 8:52 am, Ron <stecklyena...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Fred, > > 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 typehttp://localhost:3000/admin/index > that should call up the controller code, no? > > Thanks, > > Ron > > On Mar 11, 8:43 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > On 11 Mar 2008, at 15:37, Ron wrote: > > > > 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 > > > Hi Ron, > > > That looks ok. Are you sure the code in your action is getting > > executed ? > > > Fred > > > > 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? > > > > Ron--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well, so I created a separate pages controller. It works from the pages controller. localhost:3000/pages/ But it doesn''t work when I type localhost:3000/admin/index Now, when I type in admin, I get undefined method `find'' for ActionController::Caching::Pages:Module Both controllers have identical code. On Mar 11, 9:03 am, Ron <stecklyena...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hmm...I just restarted my webbrick server and it worked. That''s > strange. I thought you didn''t have to restart the server for new > actions. > > On Mar 11, 8:52 am, Ron <stecklyena...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi Fred, > > > 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 typehttp://localhost:3000/admin/index > > that should call up the controller code, no? > > > Thanks, > > > Ron > > > On Mar 11, 8:43 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > On 11 Mar 2008, at 15:37, Ron wrote: > > > > > 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 > > > > Hi Ron, > > > > That looks ok. Are you sure the code in your action is getting > > > executed ? > > > > Fred > > > > > 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? > > > > > Ron--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 11, 4:12 pm, Ron <stecklyena...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. Fred> > But it doesn''t work when I type > > localhost:3000/admin/index > > Now, when I type in admin, I get > > undefined method `find'' for ActionController::Caching::Pages:Module > > Both controllers have identical code. > > On Mar 11, 9:03 am, Ron <stecklyena...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hmm...I just restarted my webbrick server and it worked. That''s > > strange. I thought you didn''t have to restart the server for new > > actions. > > > On Mar 11, 8:52 am, Ron <stecklyena...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi Fred, > > > > 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 typehttp://localhost:3000/admin/index > > > that should call up the controller code, no? > > > > Thanks, > > > > Ron > > > > On Mar 11, 8:43 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > > On 11 Mar 2008, at 15:37, Ron wrote: > > > > > > 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 > > > > > Hi Ron, > > > > > That looks ok. Are you sure the code in your action is getting > > > > executed ? > > > > > Fred > > > > > > 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? > > > > > > Ron--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---