Last active
January 18, 2016 22:42
-
-
Save matthaliski/1ed3fdb4b32f9b001894 to your computer and use it in GitHub Desktop.
Editing a form using fields_for in Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/post.rb | |
class Post < ActiveRecord::Base | |
has_many :tags, dependent: :destroy | |
# Enable the building of complex forms | |
accepts_nested_attributes_for :tags, allow_destroy: true | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/tag.rb | |
class Tag < ActiveRecord::Base | |
belongs_to :post | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment