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
<%= 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.
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
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.