I am an new to Rails. I created a simple web app called test and database called test with ''People'' table. Then I did scaffold of Person and everything is fine. I was able to go to the index page and from there I was able to create a new person. After creating it went back to index and from there I clicked the ''edit'' and I got activerecord::recordnotfound I didn''t make any changes to the default code generated for me. Could someone tell me what could be wrong? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
take a look at the edit method in your controller, it should look something like: Person.find(params[:id]) make sure that params[:id] is not empty, since find will raise a recordnotfound exception if it can''t return any records (you can use find_by_id to avoid raising an exception in the event of no matching records found, although usually you''ll want to make sure you handle either case programmatically). Mike On 6/7/07, DBC User <dbcuser-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I am an new to Rails. I created a simple web app called test and > database called test with ''People'' table. Then I did scaffold of > Person and everything is fine. I was able to go to the index page and > from there I was able to create a new person. After creating it went > back to index and from there I clicked the ''edit'' and I got > activerecord::recordnotfound > I didn''t make any changes to the default code generated for me. > > Could someone tell me what could be wrong? > > Thanks. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Jun 7, 10:36 am, "Mike Garey" <random...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> take a look at the edit method in your controller, it should look > something like: > > Person.find(params[:id]) > > make sure that params[:id] is not empty, since find will raise a > recordnotfound exception if it can''t return any records (you can use > find_by_id to avoid raising an exception in the event of no matching > records found, although usually you''ll want to make sure you handle > either case programmatically). > > Mike > > On 6/7/07, DBC User <dbcu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I am an new to Rails. I created a simple web app called test and > > database called test with ''People'' table. Then I did scaffold of > > Person and everything is fine. I was able to go to the index page and > > from there I was able to create a new person. After creating it went > > back to index and from there I clicked the ''edit'' and I got > > activerecord::recordnotfound > > I didn''t make any changes to the default code generated for me. > > > Could someone tell me what could be wrong? > > > Thanks.- Hide quoted text - > > - Show quoted text -Thanks and yes the code is correct and as I said before I didn''t touch the code at all. I was just trying to see how the scaffold works so I didn''t change anything on the code. --~--~---------~--~----~------------~-------~--~----~ 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 Jun 7, 10:50 am, DBC User <dbcu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jun 7, 10:36 am, "Mike Garey" <random...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > take a look at the edit method in your controller, it should look > > something like: > > > Person.find(params[:id]) > > > make sure that params[:id] is not empty, since find will raise a > > recordnotfound exception if it can''t return any records (you can use > > find_by_id to avoid raising an exception in the event of no matching > > records found, although usually you''ll want to make sure you handle > > either case programmatically). > > > Mike > > > On 6/7/07, DBC User <dbcu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I am an new to Rails. I created a simple web app called test and > > > database called test with ''People'' table. Then I did scaffold of > > > Person and everything is fine. I was able to go to the index page and > > > from there I was able to create a new person. After creating it went > > > back to index and from there I clicked the ''edit'' and I got > > > activerecord::recordnotfound > > > I didn''t make any changes to the default code generated for me. > > > > Could someone tell me what could be wrong? > > > > Thanks.- Hide quoted text - > > > - Show quoted text - > > Thanks and yes the code is correct and as I said before I didn''t touch > the code at all. I was just trying to see how the scaffold works so I > didn''t change anything on the code.- Hide quoted text - > > - Show quoted text -Found the problem. In my table the primary key had a different name then id. When I change the primary key of the table to id everything worked. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---