On 7/26/06, Cameron Matheson <cameron.matheson@gmail.com>
wrote:>
> Hey guys,
>
> I''ve been playing w/ ruby for a few years now, and I finally have
a
> project that gives me an excuse to try out rails. I''ve been
liking it a
> lot, but it''s hard for me to grasp some of the concepts...
specifically,
> when do I need to make a new controller? I understand that different
> tables need their own controller, but what about other things that are
> not related to my database at all? I have created a
''Settings'' page,
> which controls various things for the view (how many entries per page,
> sort order, etc.). Right now I''ve just been sticking all that
code in
> my ''members'' controller... Is that right? Or should I
make a seperate
> Settings controller? Maybe stick it in the application controller?
>
> Thanks,
> Cameron Matheson
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
Controllers themselves aren''t directly related to tables.
That''s a models
job.
Baisically a controller should look after some logical section of your app.
It can interact with whatever models you need to achieve that. If there is
another logical section of your app, make a new controller. Logical
sections may or may not map directly to your models.
As for your settings page (action) if it makes sense to put that in your
members controller, then keep it in there. It''s probably overkill to
make a
seperate controller for one action.
Application controller is where you would put code that you want in every
controller. Most controllers inherit ApplicationController.
Also Agile Web Dev with Rails is a good book for getting to know Rails.
It''s well worth the read, especially since you already know Ruby.
Hope this helps
Cheers
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060726/9b6774b7/attachment.html