Re: [Rails] Helper or ???
On 26 January 2012 14:26, Walter Lee Davis <waltd@wdstudio.com> wrote:
> I have a strong handle on when to use a helper -- at least I think so. A helper may include some logic (not enough to belong in the model) and it presents html as its output. So I have a conceptual problem about this solution that I've built:
>
> #helpers/people_helper.rb
> def person_roles
> (%W(assistant author collector editor foreword illustrator interviewer introduction narrator notes translator) + Role.group('name').map(&:name)).uniq().sort
> end
>
> I use the output in a view, as part of a collection_select picker for a string-based attribute. This picker has a JavaScript "combobox" behavior added to it, so the editor can add new roles to the list at whim. But the output is an array. Does this invalidate my use of a helper method? Or am I thinking too much about the label "helper" here?
To me that looks more like something that should be called in the
controller and go into an @ variable for use in the view. The general
rule is setup data in the controller and display it in the view. The
method itself could go in the Role model or in a module in lib
Colin
>
> Thanks,
>
> Walter
>
> --
> 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.
>
--
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