gregbell/active_admin — Issue #803: AdminUser with nested Profile model
Author: jogalabs
Created: 2011-12-01 17:29:02+00:00
State: open

I'm trying setup the AdminUser with a nested Profile model, but I can't make it work properly.

The Profiles fields are there, but when I hit the save button, only the AdminUser data is saved/updated; Profile data is ignored. But when I enter Profile data from its page, it shows up on AdminUser edit form. But again, I just can't update Profile data from there.

Can anybody help me with that? I just don't know what to do anymore.

FILE >> app/models/admin_user.rb

has_one :profile, :dependent => :destroy
accepts_nested_attributes_for :profile, :allow_destroy => true

FILE >> app/models/profile.rb

belongs_to :admin_user

FILE >> app/admin/admin_users.rb

form :partial => 'form'

FILE >> app/views/admin/admin_users/_form.html.erb

<%= semantic_form_for [:admin, @admin_user] do |f| %>
<%= f.inputs :email %>
<%= f.inputs "My Profile" do %>
<%= f.semantic_fields_for :profile, @admin_user.profile || Profile.new do |profile| %>
<%= profile.input :name %>
<% end %>
<% end %>
<%= f.buttons %>
<% end %>