Skip to content

Instantly share code, notes, and snippets.

@Hakon
Created August 14, 2011 15:23
Show Gist options
  • Save Hakon/1144978 to your computer and use it in GitHub Desktop.
Save Hakon/1144978 to your computer and use it in GitHub Desktop.
# this one does NOT work
params[:wine] = {:bulk_price_per_dozen => 50}
@wine = Wine.new(params[:wine])
# this one ALSO does NOT work
@wine = current_seller.wines.build(params[:wine])
# this one does work
@wine = current_seller.wines.build
@wine.attributes = params[:wine]
Class Wine < ActiveRecord::Base
belongs_to :seller
before_validation :do_something_with_seller
def do_something_with_seller
# Here you have seller available
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment