[Nitro] Passing data from a controller to a template

Jonathan Buch john at oxyliquit.de
Sat Jun 3 06:04:15 EDT 2006


> Don't worry; we see this a lot in RubyLand  (I mean ruby_land).

Yes yes, this was a pun about getter/setter mentality ;)

> Yeah, but why do it like that?  Why not make the methods look like
> attribute accessors?

Because (if you don't create extra logic in those getters/setters)
they just add another redirection instead to clarify things. Ruby is
not fast in calling methods. So, my vote would be, to use the instance
variables whenever available.
But not because of the speed, it's more that the @ is a visual cue for
me, that I'm working on the data now.

> Could not one just use the controller class (i.e, some_controller.rb) to
> define data accesor methods, and omit the specific action methods?
> So that, for example, MainController would not define an 'index' method;
> index.xhtml would reference assorted methods defined in MainController
> and render the results.
> (This means that any business logic associated with the call to index
> would either be in index.xhtml, or would emerge from the calls made by
> index.xhtml to the various data accessor methods of MainController.)

I'm not really sure how this would work.. Basically you would determine the
'path' of a 'action' (meaning the index.xhtml) by its location in the
template folder?
What about nice-urls? or would it just skip the .xhtml. How do you handle
`/index/foo` or `/index?foo=bar`?
What we have now, is a tight coupling between View and Controller.. maybe
this idea would loosen this? But I'm not sure, since it sounds like the
View would have too much processing in it...
I will have to think more about this...


Feel the love

More information about the Nitro-general mailing list