Forum: Ruby on Rails Advice on the definition and use of a rails controller.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jabbar (Guest)
on 2007-01-22 00:05
(Received via mailing list)
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
Chris W. (Guest)
on 2007-01-22 00:20
(Received via mailing list)
On 1/21/07, Jabbar <removed_email_address@domain.invalid> 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 B.'s blog:
http://weblog.jamisbuck.org/

It has many great examples illustrating what goes where.

--
Chris W.
http://errtheblog.com
Jabbar (Guest)
on 2007-01-22 00:53
(Received via mailing list)
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.  Your

I 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 B.'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 B.'s log ...


On 21/01/07, Chris W. <removed_email_address@domain.invalid> wrote:
> should be, mostly, brief.  Your business logic should live in your
>
> --
> Chris W.
> http://errtheblog.com
>
> >
>


--
Thanks

  A Jabbar Azam
This topic is locked and can not be replied to.