Permalink
Browse files

Merge pull request #76 from chrismccord/master

Routing error caused by id paramter being passed record object instead of record id
  • Loading branch information...
2 parents 4d33414 + 41b14fd commit a83fbc189af395da0354fa3ab04219742cebc27a Neeraj Singh committed Jun 17, 2011
@@ -288,5 +288,12 @@ def get_reflection_for_column(klass, col)
klass.reflections.values.detect { |reflection| reflection.primary_key_name.to_sym == col.name.to_sym }
end
+ def record_id(record)
+ if record.respond_to?(:primary_key)
+ record.send(:primary_key)
+ else
+ record.id
+ end
+ end
end
end
@@ -23,7 +23,7 @@
<% columns_order(klass).each do |column| %>
<td>
<% if (column == klass.primary_key) %>
- <%= link_to(record.to_param.to_s, admin_data_path(:klass => klass.name.underscore, :id => record)) %>
+ <%= link_to(record.to_param.to_s, admin_data_path(:klass => klass.name.underscore, :id => record_id(record))) %>
<% else %>
<%=h get_value_for_column(column_native(klass, column), record) %>
<% end %>

0 comments on commit a83fbc1

Please sign in to comment.