gregbell/demo.activeadmin.info — pull request #7 by fabiolnm (2012-02-23 01:38:13+00:00)
Title: Add user_address as an example of belongs_to feature

I want to use this draft to write some docs explaining belongs_to awesome feature!

Any feedback will be appreciated.

Notes:

1) admin/users.rb
It was registered as "Customer":
ActiveAdmin.register User, :as => "Customer" do
...

but it definitelly breaks belongs_to, so I needed to remove customer declaration.

2.1) admin/user_addresses.rb
I customized the generated form to render user_id input as hidden field instead of select, because user is "already choosen" when we are using new_admin_user_user_address_path(user.id) - It doens't make sense allow to change it inside the form.

2.2) I needed update Gemfile to use ActiveAdmin head - without it, user_address form was not resolving params, used to set user_id hidden value (params[:user_id]).

3) I was able to fix and run unit tests, but I could not run functional tests (mock calls not available). Is Rspec deps necessary to be declared in Gemfile?

Thanks!