Please quote when replying. Rob Lacey wrote in post #964320: > Without opening a debate on the issue. I find the whole bad form, > conventions as interesting as it is frustrating. I need to re-use this > button helper in many views several times over for several different > buttons. Say... > > <%= button_helper(:fruit) %> > <%= button_helper(:fungi) %> > <%= button_helper(:tree) %> > > which would require calling initialize on Fungi, Fruit, Tree objects > within the helper.
No! Never initialize model objects in the helper or view. The helper and view should *always* get their model objects from the controller. > If you assigned an instance variable in each > controller action for everytime you used the helper you'd actually > make re-using the code in many different places more awkward. Then you can use a before_filter. > Not to > mention if the number and type of buttons was also dynamic. Easy. Set that all in the controller. If you're having trouble with a particular case, please post details. > Conventions are a good building block, but on occasion you may need to > stray from them to make life easier. Not until you fully understand how to work with them. And the convention in Rails MVC architecture is that it is *never* appropriate for the model and view/helper to talk to each other. The controller *must* mediate. > > Do you know of any 'Bad Form vs Good Form' Rails articles, I'd be > interested in ready some. Look up articles on Rails MVC. > > RobL Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.