I''m going to take another stab at this question (my first one received no replies): I have two models: Author has_many: books Book has_one: author I have two tables: authors id ... books id author_id ... I let the scaffolding fly and it created the CRUD goodness for each model, as expected. However, I want to have only one view/controller "set" for both models; when I refer to "set", I mean having a generic controller called Library with methods for create, edit, show, destroy, and list, but these methods would access and manipulate this combined data set of authors and their books from both models. After sifting through both the controllers and views and adding those relationships (described above) is there any way to: a) run the scaffolding again so that it will take these new relationships into account? b) if not, how should I proceed? I am a complete Ruby/RoR/MVC luddite and am open to any suggestions here. Thanks
joey__
2006-Mar-28 21:03 UTC
[Rails] Re: combining two models in one controller/view "set"
gravy face wrote:> I''m going to take another stab at this question (my first one received > no replies): > > I have two models: > > Author > has_many: books > > Book > has_one: author > > I have two tables: > > authors > id > ... > > books > id > author_id > ... > > I let the scaffolding fly and it created the CRUD goodness for each > model, as expected. > > However, I want to have only one view/controller "set" for both > models; when I refer to "set", I mean having a generic controller > called Library with methods for create, edit, show, destroy, and list, > but these methods would access and manipulate this combined data set > of authors and their books from both models. > > After sifting through both the controllers and views and adding > those relationships (described above) is there any way to: > > a) run the scaffolding again so that it will take these new > relationships into account? > b) if not, how should I proceed? > > I am a complete Ruby/RoR/MVC luddite and am open to any suggestions > here. > > ThanksScaffolding[1]: Scaffolding is a temporary framework used to support people and material in the construction or repair of buildings and other large structures. You cannot do this with scaffolding, you need to write this yourself. I suggest you buy or read Agile Web Development with rails. Joey__ [1] http://en.wikipedia.org/wiki/Scaffolding -- Posted via http://www.ruby-forum.com/.
GravyFace
2006-Mar-28 21:47 UTC
[Rails] Re: combining two models in one controller/view "set"
As for the book, I have it, I haven''t had a chance to read it yet (only skimmed through it). And as for the answer, I was hoping this was a common "pattern" that somebody has stumbled across before and perhaps blogged or wiki''ed it; Google came up with nothing although my terms are pretty ambiguous. +1 for the burn -- but at least I got a response this time. :) On 3/28/06, joey__ <cardologist@gmail.com> wrote:> gravy face wrote: > > I''m going to take another stab at this question (my first one received > > no replies): > > > > I have two models: > > > > Author > > has_many: books > > > > Book > > has_one: author > > > > I have two tables: > > > > authors > > id > > ... > > > > books > > id > > author_id > > ... > > > > I let the scaffolding fly and it created the CRUD goodness for each > > model, as expected. > > > > However, I want to have only one view/controller "set" for both > > models; when I refer to "set", I mean having a generic controller > > called Library with methods for create, edit, show, destroy, and list, > > but these methods would access and manipulate this combined data set > > of authors and their books from both models. > > > > After sifting through both the controllers and views and adding > > those relationships (described above) is there any way to: > > > > a) run the scaffolding again so that it will take these new > > relationships into account? > > b) if not, how should I proceed? > > > > I am a complete Ruby/RoR/MVC luddite and am open to any suggestions > > here. > > > > Thanks > Scaffolding[1]: > Scaffolding is a temporary framework used to support people and material > in the construction or repair of buildings and other large structures. > > You cannot do this with scaffolding, you need to write this yourself. I > suggest you buy or read Agile Web Development with rails. > > Joey__ > [1] http://en.wikipedia.org/wiki/Scaffolding > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Jeremy Evans
2006-Mar-28 23:32 UTC
[rails] combining two models in one controller/view "set"
On 3/28/06, GravyFace <gravyface@gmail.com> wrote:> After sifting through both the controllers and views and adding > those relationships (described above) is there any way to: > > a) run the scaffolding again so that it will take these new > relationships into account? > b) if not, how should I proceed? > > I am a complete Ruby/RoR/MVC luddite and am open to any suggestions here.It might not be completely what you want, but you could look into the Scaffolding Extensions Plugin: http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin.
Perfect, thanks man. I''m not planning on leaning on the scaffolding crutch forever, but c''mon, who didn''t switch to Rails because of it? :) On 3/28/06, Jeremy Evans <jeremyevans0@gmail.com> wrote:> On 3/28/06, GravyFace <gravyface@gmail.com> wrote: > > After sifting through both the controllers and views and adding > > those relationships (described above) is there any way to: > > > > a) run the scaffolding again so that it will take these new > > relationships into account? > > b) if not, how should I proceed? > > > > I am a complete Ruby/RoR/MVC luddite and am open to any suggestions here. > > It might not be completely what you want, but you could look into the > Scaffolding Extensions Plugin: > http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Jeremy Huffman
2006-Mar-29 02:08 UTC
[rails] combining two models in one controller/view "set"
The sooner you ditch scaffold the sooner you will grok rails. I swear that feature has done as much harm as good. On 3/28/06, GravyFace <gravyface@gmail.com> wrote:> Perfect, thanks man. I''m not planning on leaning on the scaffolding > crutch forever, but c''mon, who didn''t switch to Rails because of it? > :) > > On 3/28/06, Jeremy Evans <jeremyevans0@gmail.com> wrote: > > On 3/28/06, GravyFace <gravyface@gmail.com> wrote: > > > After sifting through both the controllers and views and adding > > > those relationships (described above) is there any way to: > > > > > > a) run the scaffolding again so that it will take these new > > > relationships into account? > > > b) if not, how should I proceed? > > > > > > I am a complete Ruby/RoR/MVC luddite and am open to any suggestions here. > > > > It might not be completely what you want, but you could look into the > > Scaffolding Extensions Plugin: > > http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jeremy Huffman http://www.jeremyhuffman.com