Hello all, I''m a java developer who has used tapestry for web development. I''m trying to use rails now and am finding it very interesting. However I''m by confused by the amount of functionality that should be included in a controller. In tapestry I am used to having multiple components on a page, where each components logic is encapsulated in its own class, and the logic for the page is encapsulated in a page class. Can I think of the rails controller as a page class, where the logic for each page is embedded in it and most of the actions in the controller return the same view? For some of you this might seem trivial, but until I get my head round this I am not going to be very productive. I have read AWD 2nd edition and am still not not sure how to approach the controllers. Can anybody help? -- Thanks A Jabbar Azam --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris Wanstrath
2007-Jan-21 22:19 UTC
Re: Advice on the definition and use of a rails controller.
On 1/21/07, Jabbar <ajazam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Can I think of the rails controller as a page class, where the logic > for each page is embedded in it and most of the actions in the > controller return the same view?I would say: Rails is not Tapestry. Forget Tapestry. Controller actions should ''set up'' the environment for a view. They should be, mostly, brief. Your business logic should live in your models. Your display logic should live in view helpers. Your controller just needs to glue some things together and prepare instance variables for your view. Different actions in a controller usually each have a unique view and may not even share the same layout. Get a hot cup of tea and spend some time reading Jamis Buck''s blog: http://weblog.jamisbuck.org/ It has many great examples illustrating what goes where. -- Chris Wanstrath http://errtheblog.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 -~----------~----~----~----~------~----~------~--~---
Hello Chris,> I would say: Rails is not Tapestry. Forget Tapestry.Unfortunately I have legacy apps which need maintaining and some are under development :( I think knowing other languages and frameworks will make you a better programmer ... fortunately Ruby and Rails gives me the same excitement as I had when I had my Commodore 64 and was writing simple text games for it in Commodore Basic.> Controller actions should ''set up'' the environment for a view. They > should be, mostly, brief. Your business logic should live in your > models. Your display logic should live in view helpers. YourI had the same feelings about view helpers, but weren''t sure if it was the rails ways. I find it difficult to not think about components, but I guess this is best practice in the rails world.> Get a hot cup of tea and spend some time reading Jamis Buck''s blog: > http://weblog.jamisbuck.org/You mean a cup of java ;) Don''t want to start anything, but I think both languages can coexist e.g. JRuby. I will definitely read all of Jamis Buck''s log ... On 21/01/07, Chris Wanstrath <chris-G5sj8e7vJc8@public.gmane.org> wrote:> > On 1/21/07, Jabbar <ajazam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Can I think of the rails controller as a page class, where the logic > > for each page is embedded in it and most of the actions in the > > controller return the same view? > > I would say: Rails is not Tapestry. Forget Tapestry. > > Controller actions should ''set up'' the environment for a view. They > should be, mostly, brief. Your business logic should live in your > models. Your display logic should live in view helpers. Your > controller just needs to glue some things together and prepare > instance variables for your view. Different actions in a controller > usually each have a unique view and may not even share the same > layout. > > Get a hot cup of tea and spend some time reading Jamis Buck''s blog: > http://weblog.jamisbuck.org/ > > It has many great examples illustrating what goes where. > > -- > Chris Wanstrath > http://errtheblog.com > > > >-- Thanks A Jabbar Azam --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---