Hiall, If I have say 10 tables that i would like to wrap up in 1 view to manipulate data inside these tables, do I then need 10 model.rb files for all 10 tables plus 1 for the view, or do I just need 1 model.rb file for the view ? cheers Martin
You would not use a view for the model as such. A view is called from a Controller and can be called anything you want. The controller method would prepare all the model instances that you require, and provide them to either the default view or the view specified. On 5/1/06, Martin Gamsjaeger <gamsnjaga@gmail.com> wrote:> > Hiall, > > If I have say 10 tables that i would like to wrap up in 1 view to > manipulate data inside these tables, do I then need 10 model.rb files > for all 10 tables plus 1 for the view, or do I just need 1 model.rb > file for the view ? > > cheers > Martin > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060501/54bb325f/attachment.html
Hi Liquid, I''m not sure you got me right, excuses if I''m wrong. I didn''t mean rails views, but database views, as in "create view blabla as select * from ..." cheers Martin On 5/1/06, Liquid <has.sox@gmail.com> wrote:> You would not use a view for the model as such. > > A view is called from a Controller and can be called anything you want. The > controller method would prepare all the model instances that you require, > and provide them to either the default view or the view specified. > > > On 5/1/06, Martin Gamsjaeger <gamsnjaga@gmail.com> wrote: > > > Hiall, > > If I have say 10 tables that i would like to wrap up in 1 view to > manipulate data inside these tables, do I then need 10 model.rb files > for all 10 tables plus 1 for the view, or do I just need 1 model.rb > file for the view ? > > cheers > Martin > > _______________________________________________ > 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 > > >
Ok... Sorri for the misunderstanding On 5/1/06, Martin Gamsjaeger <gamsnjaga@gmail.com> wrote:> > Hi Liquid, > > I''m not sure you got me right, excuses if I''m wrong. I didn''t mean > rails views, but database views, as in "create view blabla as select * > from ..." > > cheers > Martin > > On 5/1/06, Liquid <has.sox@gmail.com> wrote: > > You would not use a view for the model as such. > > > > A view is called from a Controller and can be called anything you > want. The > > controller method would prepare all the model instances that you > require, > > and provide them to either the default view or the view specified. > > > > > > On 5/1/06, Martin Gamsjaeger <gamsnjaga@gmail.com> wrote: > > > > > Hiall, > > > > If I have say 10 tables that i would like to wrap up in 1 view to > > manipulate data inside these tables, do I then need 10 model.rb files > > for all 10 tables plus 1 for the view, or do I just need 1 model.rb > > file for the view ? > > > > cheers > > Martin > > > > _______________________________________________ > > 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 > > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060501/8b4b8ee4/attachment.html
On May 1, 2006, at 5:03 AM, Martin Gamsjaeger wrote:> Hiall, > > If I have say 10 tables that i would like to wrap up in 1 view to > manipulate data inside these tables, do I then need 10 model.rb files > for all 10 tables plus 1 for the view, or do I just need 1 model.rb > file for the view ?Only do what you think is necessary. If you''re just doing some reads... you only need the view... assuming that is all the data that you''ll need. -Robby Robby Russell Founder & Executive Director PLANET ARGON, LLC Ruby on Rails Development, Consulting & Hosting www.planetargon.com www.robbyonrails.com +1 503 445 2457 +1 877 55 ARGON [toll free] +1 815 642 4968 [fax]
Hi Robby, If I understand correct this means that if I want the underlying tables to be updatable via the view, i need to tell ActiveRecord about the underlying tables i.e. give it model classes, and if I don''t need them updatable then only one model class for the view is sufficient? As my tables need to be updatable via the view this wouldn''t leave me with less model.rb files I guess :( I was asking this question because I am a little bit frustrated about the fact that obviously rails needs one .rb file per model ... which is really polluting my app/models subfolder and makes files hard to find. (I have about 200 files as I have that much tables ... If there would be a way to tell rails to look for more than one model class per .rb file, I would be very interested in that!!! If I currently try to put more than one model class per .rb file, rails complains about missing file "modelname.rb" .. Any opinions? Martin On 5/1/06, Robby Russell <robby.lists@planetargon.com> wrote:> > On May 1, 2006, at 5:03 AM, Martin Gamsjaeger wrote: > > > Hiall, > > > > If I have say 10 tables that i would like to wrap up in 1 view to > > manipulate data inside these tables, do I then need 10 model.rb files > > for all 10 tables plus 1 for the view, or do I just need 1 model.rb > > file for the view ? > > Only do what you think is necessary. If you''re just doing some > reads... you only need the view... assuming that is all the data that > you''ll need. > > -Robby > > Robby Russell > Founder & Executive Director > > PLANET ARGON, LLC > Ruby on Rails Development, Consulting & Hosting > > www.planetargon.com > www.robbyonrails.com > > +1 503 445 2457 > +1 877 55 ARGON [toll free] > +1 815 642 4968 [fax] > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I thought that one could place model files into their class named folder, so for example: /app/models/className/classNameForModel.rb Maybe I''m mistaken or slightly delusional but likely both o.O And if it doesn''t work like the stated behavior above ... then it ought to be ;) Should help you in file soup, at least things would be tucked nicely away in their own baggies. JY On 5/1/06, Martin Gamsjaeger <gamsnjaga@gmail.com> wrote:> > Hi Robby, > > If I understand correct this means that if I want the underlying > tables to be updatable via the view, i need to tell ActiveRecord about > the underlying tables i.e. give it model classes, and if I don''t need > them updatable then only one model class for the view is sufficient? > > As my tables need to be updatable via the view this wouldn''t leave me > with less model.rb files I guess :( I was asking this question because > I am a little bit frustrated about the fact that obviously rails needs > one .rb file per model ... which is really polluting my app/models > subfolder and makes files hard to find. (I have about 200 files as I > have that much tables ... If there would be a way to tell rails to > look for more than one model class per .rb file, I would be very > interested in that!!! If I currently try to put more than one model > class per .rb file, rails complains about missing file "modelname.rb" > .. > > Any opinions? > > Martin > > On 5/1/06, Robby Russell <robby.lists@planetargon.com> wrote: > > > > On May 1, 2006, at 5:03 AM, Martin Gamsjaeger wrote: > > > > > Hiall, > > > > > > If I have say 10 tables that i would like to wrap up in 1 view to > > > manipulate data inside these tables, do I then need 10 model.rb files > > > for all 10 tables plus 1 for the view, or do I just need 1 model.rb > > > file for the view ? > > > > Only do what you think is necessary. If you''re just doing some > > reads... you only need the view... assuming that is all the data that > > you''ll need. > > > > -Robby > > > > Robby Russell > > Founder & Executive Director > > > > PLANET ARGON, LLC > > Ruby on Rails Development, Consulting & Hosting > > > > www.planetargon.com > > www.robbyonrails.com > > > > +1 503 445 2457 > > +1 877 55 ARGON [toll free] > > +1 815 642 4968 [fax] > > > > > > _______________________________________________ > > 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 > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060501/5fc1a4c7/attachment-0001.html
Hi Joe, Correct me if I am slightly delusional :) but I can''t really follow your idea. In which way would your suggestion prevent tasteless file soups? If className is a folder, then which files would you expect underneath it? I have a table "foos" leading to a class "Foo" ... If I now have a folder "Foo" below apps/models, which files should I place there? Maybe you meant a folder for each controllerName, which would help a little, but still would be too inflexible in general, imo. All I really want, is that Rails goes looking for model classes in every .rb file it finds below app/models, and if it finds 1+ classes per file, this shouldn''t matter. Specifically, it shouldn''t be necessary for model class Foo to reside in app/models/foo.rb, it should be possible for this class to reside in app/models/bar.rb as well. Any opinions? Martin On 5/1/06, Joe Youngquist <joemanfoo@gmail.com> wrote:> I thought that one could place model files into their class named folder, so > for example: > > /app/models/className/classNameForModel.rb > > Maybe I''m mistaken or slightly delusional but likely both o.O And if it > doesn''t work like the stated behavior above ... then it ought to be ;) > > Should help you in file soup, at least things would be tucked nicely away in > their own baggies. > > JY > > > On 5/1/06, Martin Gamsjaeger < gamsnjaga@gmail.com> wrote: > > Hi Robby, > > > > If I understand correct this means that if I want the underlying > > tables to be updatable via the view, i need to tell ActiveRecord about > > the underlying tables i.e. give it model classes, and if I don''t need > > them updatable then only one model class for the view is sufficient? > > > > As my tables need to be updatable via the view this wouldn''t leave me > > with less model.rb files I guess :( I was asking this question because > > I am a little bit frustrated about the fact that obviously rails needs > > one .rb file per model ... which is really polluting my app/models > > subfolder and makes files hard to find. (I have about 200 files as I > > have that much tables ... If there would be a way to tell rails to > > look for more than one model class per .rb file, I would be very > > interested in that!!! If I currently try to put more than one model > > class per .rb file, rails complains about missing file "modelname.rb" > > .. > > > > Any opinions? > > > > Martin > > > > On 5/1/06, Robby Russell < robby.lists@planetargon.com> wrote: > > > > > > On May 1, 2006, at 5:03 AM, Martin Gamsjaeger wrote: > > > > > > > Hiall, > > > > > > > > If I have say 10 tables that i would like to wrap up in 1 view to > > > > manipulate data inside these tables, do I then need 10 model.rb files > > > > for all 10 tables plus 1 for the view, or do I just need 1 model.rb > > > > file for the view ? > > > > > > Only do what you think is necessary. If you''re just doing some > > > reads... you only need the view... assuming that is all the data that > > > you''ll need. > > > > > > -Robby > > > > > > Robby Russell > > > Founder & Executive Director > > > > > > PLANET ARGON, LLC > > > Ruby on Rails Development, Consulting & Hosting > > > > > > www.planetargon.com > > > www.robbyonrails.com > > > > > > +1 503 445 2457 > > > +1 877 55 ARGON [toll free] > > > +1 815 642 4968 [fax] > > > > > > > > > _______________________________________________ > > > 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 > > > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >