Skip to content

Instantly share code, notes, and snippets.

@aviflombaum
Created July 25, 2012 02:57
Show Gist options
  • Select an option

  • Save aviflombaum/3174121 to your computer and use it in GitHub Desktop.

Select an option

Save aviflombaum/3174121 to your computer and use it in GitHub Desktop.
app/models/song.rb
<%= f.fields_for :artist do |artist_form| %>
<div class="field">
<%= artist_form.label :name, 'Artist Name' %><br />
<%= artist_form.text_field :name %>
</div>
<% end %>
# app/models/song.rb
class Song < ActiveRecord::Base
belongs_to :artist
accepts_nested_attributes_for :artist
attribute_accessible :artist_id, :artist_attributes
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment