Skip to content

Instantly share code, notes, and snippets.

@ericcf
Last active May 3, 2016 13:38
Show Gist options
  • Save ericcf/f4da02ca5bb80d889131f603448ee10c to your computer and use it in GitHub Desktop.
Save ericcf/f4da02ca5bb80d889131f603448ee10c to your computer and use it in GitHub Desktop.
$ rails -v
Rails 4.2.6
$ rails new nested_update
...
$ cd nested_update
$ echo "gem 'rails_admin', '~> 0.8.1'" >> Gemfile
$ bundle
...
$ rails g rails_admin:install
...
<enter>
...
$ rails g model person name
...
$ rails g model cat person:references name
...
$ rails g model dog person:references name
...
$ rake db:migrate
...
$ vi app/models/person.rb [see file below]
$ rails s
...
$ open http://localhost:3000/admin/person/new [in a new tab]
class Person < ActiveRecord::Base
has_one :cat
has_one :dog
accepts_nested_attributes_for :cat, update_only: true
accepts_nested_attributes_for :dog, update_only: false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment