1. You could create a partial with code between for and end, not
including them. Then u can render that partial using render :partial
=> 'something', :collection => @projects.
2. dom_id(project) is same as "project_#{project.id}"
3. Try content_tag_for(:li, project, ...) instead of <li id="<%=
project_id %>"...You can read more about all of these methods in rails documentation page. On Jan 1, 11:33 pm, Bill Devaul <[email protected]> wrote: > I am new to this and need some help DRYing this view code: > > <div style="float: left;"> > <h3>drop task name</h3> > <ul>Projects > <% for project in @projects %> > <% project_id = "project_#{project.id}" %> > <li id="<%= project_id %>" class="project" style="background-color: > #CCC; margin: 0 20px 2px 0;"> > <%=h project.name %> > </li> > > <% #TODO need to DRY up the drop_receiving_element, perhaps with a > helper%> > > <%= drop_receiving_element( > project_id, # The id of the receiving > element > :accept => "task_name", # The CSS class of the > dropped element > #The action to call (update the database and then update the > project name field for that task via RJS) > :url => { :controller => :tasks, :action => :update, > 'task[project_id]'=> project.id.to_s } > #TODO there is probably a better way to refer to the task's > project_id so that we can avoid the extra line in the update action of > the task controller > ); %> > <% end %> > </ul> > > <ul>Contexts > <% for context in @contexts %> > <% context_id = "context_#{context.id}" %> > <li id="<%= context_id %>" class="context" style="background-color: > #CCC; margin: 0 20px 2px 0;"> > <%=h context.name %> > </li> > <%= drop_receiving_element( > context_id, # The id of the receiving > element > :accept => "task_name", # The CSS class of the > dropped elememt > #The action to call (update the database and then update the > project name field for that task via RJS) > :url => { :controller => :tasks, :action => :update, > 'task[context_id]'=> context.id.to_s } > #TODO there is probably a better way to refer to the task's > context_id so that we can avoid the extra line in the update action of > the task controller > ); %> > <% end %> > </ul> > </div> > > What is the best way to do this? > > Thanks, > Bill > -- > 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 -~----------~----~----~----~------~----~------~--~---

