Skip to content

Instantly share code, notes, and snippets.

@breinz
Created July 8, 2013 14:11
Show Gist options
  • Save breinz/5949135 to your computer and use it in GitHub Desktop.
Save breinz/5949135 to your computer and use it in GitHub Desktop.
# 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