Topic: DRY Help

Greetings all...

I have a DRY related question as this repetition is driving me insane. All my controllers share the common CRUD controllers but I've decided to not go RESTful as I prefer combining the new and create actions in a single action. Is there a way to dry up my new.rhtml and edit.rhtml as they are identical across all controllers.

new.rhtml and edit.rhtml look like this:

<% form_for :model, :url=>{:action=>params[:action]}, :builder=>LabeledFormBuilder do |f| %>
    <%= render :partial=>"form", :locals=>{:save_button=>"Save", :f=>f} %>
<% end %>

Is there maybe a way of DRY-ing it up with partials or another way i'm not aware of?

Thanx guys

Re: DRY Help

Partials are the way to go.

Put that code in a partial (e.g. _mypartial.rhtml) and then replace the contents of your new and edit files with:

render(:partial => 'mypartial')

Re: DRY Help

Hot dog dude!!! Exactly what I was looking for... So basically I'm rendering partials in partials...