Created
July 8, 2013 14:11
-
-
Save breinz/5949135 to your computer and use it in GitHub Desktop.
This file contains 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
# Updating a Page creates a new Path, even if this isnt changed ... is it normal ? | |
# Page model | |
class Page < ActiveRecord::Base | |
attr_accessible :path, :path_attributes | |
has_one :path, :as => :pathable, :dependent => :destroy | |
accepts_nested_attributes_for :path | |
end | |
# Path model | |
class Path < ActiveRecord::Base | |
attr_accessible :path | |
belongs_to :pathable, polymorphic: true | |
end | |
# Page _form.html.haml | |
=form_for @page do |f| | |
=f.label :path | |
=fields_for "page[path_attributes]", @page.path do |path_form| | |
=path_form.text_field :path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment