Hi, I just started with rails, and thought it made sense to go with 2.0 ( know this isn''t necessarily a majority opinion ;-) I have an application which will potentially be used for a number of towns, each one of which might be quite different. I''m just working on one, ''mytown'', for now. Each town has it''s own admin section. So urls look like http://domain/Mytown/[rest stuff] or http://domain/Mytown/admin/[rest stuff] The top level (non-admin) bit is currently working ok, on mainly static files (just using some partials, layouts etc). I haven''t attempted anything really dynamic yet. The simplest part of the admin section just manages a list of surnames. So, for the admin section, I used: ruby script/generate scaffold mytown::admin::surnames surname:string prefix:string http://localhost:3000/mytown/admin/surnames gets routed to the Mytown::Admin::SurnamesController ok, but throws an error: You have a nil object when you didn''t expect it! The error occurred while evaluating nil./ on the line @mytown/admin_surnames = Mytown::Admin::Surnames.find(:all) The problem seems to be the slash in the variable name. If I change this, of course I then get ''no such variable'' type errors all down the line. So, my question is: am I trying to do something I really shouldn''t be with this kind of nesting, or should I carry on just manually changing stuff bit by bit till it works? I''ve been following the second approach so far, but it does feel like rails is something you have to fight at every step, which is surely a sign that I''m going badly wrong somewhere. Anyone? Thanks Graham -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Scaffold for admin parts of the app is a pain because you have to manually change all the routes used in the generated views. I would create model, controller and views separately. Since it is easier. On Dec 15, 2007 9:06 AM, Graham Seaman <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > > I just started with rails, and thought it made sense to go with 2.0 ( > know this isn''t necessarily a majority opinion ;-) > > I have an application which will potentially be used for a number of > towns, each one of which might be quite different. I''m just working on > one, ''mytown'', for now. > > Each town has it''s own admin section. > > So urls look like http://domain/Mytown/[rest<http://domain/Mytown/%5Brest>stuff] or > http://domain/Mytown/admin/[rest <http://domain/Mytown/admin/%5Brest>stuff] > > The top level (non-admin) bit is currently working ok, on mainly static > files (just using some partials, layouts etc). I haven''t attempted > anything really dynamic yet. > > The simplest part of the admin section just manages a list of surnames. > So, for the admin section, I used: > > ruby script/generate scaffold mytown::admin::surnames surname:string > prefix:string > > > http://localhost:3000/mytown/admin/surnames gets routed to the > Mytown::Admin::SurnamesController ok, but throws an error: > > You have a nil object when you didn''t expect it! > The error occurred while evaluating nil./ > > on the line > > @mytown/admin_surnames = Mytown::Admin::Surnames.find(:all) > > The problem seems to be the slash in the variable name. If I change > this, of course I then get ''no such variable'' type errors all down the > line. > > So, my question is: am I trying to do something I really shouldn''t be > with this kind of nesting, or should I carry on just manually changing > stuff bit by bit till it works? I''ve been following the second approach > so far, but it does feel like rails is something you have to fight at > every step, which is surely a sign that I''m going badly wrong somewhere. > > Anyone? > > Thanks > Graham > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bala Paranj wrote:> Scaffold for admin parts of the app is a pain because you have to > manually > change all the routes used in the generated views. > > I would create model, controller and views separately. Since it is > easier. > > On Dec 15, 2007 9:06 AM, Graham Seaman > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>That''s fine if you know what they should look like. But I''m new to this, and I don''t. I was hoping to use the scaffold-generated code to learn what a simple application should look like, then go from there. But if the scaffold output is buggy, how do you start? I''ve been trying to follow through the activeresource code to see if I can work things out. It seems to me from that that maybe the problem is that you can only have a single ''prefix'', and the fact that I am trying to use two (/mytown/admin) is the cause of all the problems? Graham -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I think your problem is due to nested resource. When you nest, the parent object must be loaded in a before filter before you can perform any CRUD operation on it. Check out the Rails 2.0 screencast: http://www.akitaonrails.com/2007/12/10/the-first-rails-2-0-screencast-english On Dec 16, 2007 4:25 AM, Graham Seaman <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Bala Paranj wrote: > > Scaffold for admin parts of the app is a pain because you have to > > manually > > change all the routes used in the generated views. > > > > I would create model, controller and views separately. Since it is > > easier. > > > > On Dec 15, 2007 9:06 AM, Graham Seaman > > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > That''s fine if you know what they should look like. But I''m new to this, > and I don''t. I was hoping to use the scaffold-generated code to learn > what a simple application should look like, then go from there. But if > the scaffold output is buggy, how do you start? I''ve been trying to > follow through the activeresource code to see if I can work things out. > It seems to me from that that maybe the problem is that you can only > have a single ''prefix'', and the fact that I am trying to use two > (/mytown/admin) is the cause of all the problems? > > Graham > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---