Skip to content

Instantly share code, notes, and snippets.

@batasrki
Created October 2, 2011 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save batasrki/1258018 to your computer and use it in GitHub Desktop.
Save batasrki/1258018 to your computer and use it in GitHub Desktop.
Example model preset fields
class Job < ActiveRecord::Base
def preset_fields
if category.name == "Repair" || category.name == "Maintenance"
quote_sections.create!(:description => "Labour", :amount => 0)
quote_sections.create!(:description => "Materials", :amount => 0)
quote_sections.create!(:description => "Travel", :amount => 0)
quote_sections.create!(:description => "Courier", :amount => 0)
end
category.base_projects.each do |bp|
projects.create!(:category => bp.project_category)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment