Skip to content

Instantly share code, notes, and snippets.

@evanfarrar
Created April 9, 2009 19:29
Show Gist options
  • Save evanfarrar/92683 to your computer and use it in GitHub Desktop.
Save evanfarrar/92683 to your computer and use it in GitHub Desktop.
- def self.create_with_dependencies(attrs = nil, &block)
- if(attrs[:pick_up_place] and !attrs[:pick_up_place].is_a?(Place))
- attrs[:pick_up_place] = Place.create(attrs[:pick_up_place])
- end
- if(attrs[:drop_off_place] and !attrs[:drop_off_place].is_a?(Place))
- attrs[:drop_off_place] = Place.create(attrs[:drop_off_place])
- end
- create_without_dependencies(attrs, &block)
- end
- class_eval do
- class << self
- alias_method_chain :create, :dependencies
- end
- end
+ accepts_nested_attributes_for :pick_up_place, :drop_off_place
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment