I tend to agree with this - one-liners typically go into helpers in my code, while anything longer is factored out into a partial. It can also be helpful to have a helper which crunches some parameters and then calls a partial. But that style is partly driven by writing a lot of DRYML...
As for the suggestions for to_options - that can be useful sometimes, but it's getting (IMHO) dangerously close to sticking controller/view code in the model (especially the prompt text). Now, if you want to only have *some* of the models on the menu (ie, you're doing Model.find (conditions).map ...) then the first bit of that definitely belongs in the model. --Matt Jones On Aug 23, 12:29 am, Alpha Blue <[email protected]> wrote: > There are a few core practices you can follow with view templates and > attempting a DRY concept. > > Partials are fine if you have a lot of repeating HTML in many of your > views because you can use a partial for table structures etc. As an > example, if you are creating a large table and that table needs to be > used in several views within the same controller, you can use a partial > for the other views. > > However, when working with actual code, I like to work with helpers. > The best practice is not to include too much code functionality in your > views but move those to a helper if you find yourself needing the same > one over and over. > > You should follow these basic things: > > Views are meant for html and all things that represent the display your > users see. Your controllers are the director that talks to your models > and to your views. When you need a database call, the controller talks > to the model and the model retrieves the data and hands it back to the > controller, who then hands it back to the view. > > Don't make the mistake of trying to skip the MVC architecture in your > project. If you form bad habits they are hard to break. > > -- > Posted viahttp://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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

