Skip to content

Instantly share code, notes, and snippets.

@vl3
Created March 17, 2014 05:02
Show Gist options
  • Save vl3/9594226 to your computer and use it in GitHub Desktop.
Save vl3/9594226 to your computer and use it in GitHub Desktop.
ActiveAdmin.register Band do
permit_params :name, :description, artists_attributes: [:id]
# nested form to edit and new
form do |f|
f.inputs "Band" do
f.input :name
f.input :description
f.input :artists, :as => :select, :input_html => { :multiple => true }
end
f.actions
end
controller do
def create
@band = Band.new(permitted_params[:band])
@band.artists << Artist.find(params[:band][:artist_ids].drop(2))
create!
end
def update
@band.update(params[:band])
update!
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment