Created
October 2, 2011 21:50
-
-
Save batasrki/1258018 to your computer and use it in GitHub Desktop.
Example model preset fields
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
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