Thursday, October 7, 2010

[Rails] Re: Re: Drop-down menu from a belongs_to association

Walter Davis wrote:
[...]
> Collection_select is a view helper, so that's where it belongs -- in
> the View.

Right.

> The collection you pass to it could / should be marshalled
> in the controller (at least that's how it looks from here).

Correct.

> I have
> seen view code on StackOverflow that included the data request, but I
> believe that is flat-out wrong.

You are correct here too. The view should absolutely never touch the
DB. I'm not even sure it should call too many model methods; I want to
start playing around with Mustache to enforce that...

> I would try this: Gather up your
> collection that you wish to present as a select, and save it as a
> class variable in the controller.

No, that should be an @instance variable.

> Back in your view, pass a symbol of
> the same name to your collection_select where it asks for the
> collection in the parameters.

No! Why the hell would you do that? Just give it the name of the
@instance variable.

>
> Walter

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
--
Posted via http://www.ruby-forum.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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate