Reputation: 27
I wanted to make a form for creating and updating a model, with support for adding/editing translations for multiple languages inline.
This is how my form looks like:
<%= form_for([:admin, @category], remote: true) do |f| %>
<% Category.globalize_attribute_names.each do |lang| %>
<div class="field">
<%= f.label lang %><br>
<%= f.text_field lang %>
</div>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
Strangely, everything works fine when I`m creating a model. But when I try to edit it I get this error:
undefined method `name_en' for #Category::Translation:0x007f3ce896afd8>
I said strangely, because it works fine in the console. When i type:
Category.friendly.find("men-shoes").name_en
everything works fine. (I`m using friendlyID gem).
I have no idea what the problem could be. I even don`t know why is it fetching Category::Translation, should`n it be just Category?
Thanks
Upvotes: 1
Views: 589