Skip to content

Instantly share code, notes, and snippets.

@clyfe
Created March 1, 2011 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clyfe/850091 to your computer and use it in GitHub Desktop.
Save clyfe/850091 to your computer and use it in GitHub Desktop.
How to wire record for AS cancan bridge
<table cellpadding="0" cellspacing="0">
<% @record = column.association.klass.new -%>
<%
case parent_record
when DocumentItem then @record.project_id = parent_record.management_process.project_id
when Project then @record.project_id = parent_record.project_id
end
%>
<%= render :partial => 'horizontal_subform_header', :locals => {:parent_record => parent_record} %>
<tbody id="<%= sub_form_list_id(:association => column.name) %>">
<% associated.each_index do |index| %>
<% @record = associated[index] -%>
<% if @record.errors.count -%>
<tr class="association-record-errors">
<td colspan="<%= active_scaffold_config_for(@record.class).subform.columns.length + 1 %>" id="<%= element_messages_id :action => @record.class.name.underscore, :id => "#{parent_record.id}-#{index}" %>">
<%= active_scaffold_error_messages_for :record, :object_name => @record.class.model_name.human.downcase %>
</td>
</tr>
<% end %>
<%= render :partial => 'horizontal_subform_record', :locals => {:scope => column_scope(column), :parent_record => parent_record, :column => column, :locked => @record.new_record? && @record == associated.last} %>
<% end -%>
</tbody>
</table>
<%= render :partial => 'form_association_footer', :locals => {:parent_record => parent_record, :column => column, :associated => associated} -%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment