Class: SponsoredProjectEffort
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SponsoredProjectEffort
- Defined in:
- app/models/sponsored_project_effort.rb
Class Method Summary collapse
- .emails_business_manager(an_effort_id) ⇒ Object
- .new_from_sponsored_project_allocation(allocation) ⇒ Object
Instance Method Summary collapse
Class Method Details
.emails_business_manager(an_effort_id) ⇒ Object
33 34 35 36 37 |
# File 'app/models/sponsored_project_effort.rb', line 33 def self.emails_business_manager(an_effort_id) effort = SponsoredProjectEffort.find(an_effort_id) SponsoredProjectEffortMailer.deliver_changed_allocation_email_to_business_manager(effort.sponsored_project_allocation.user, effort.month, effort.year) end |
.new_from_sponsored_project_allocation(allocation) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/models/sponsored_project_effort.rb', line 24 def self.new_from_sponsored_project_allocation(allocation) SponsoredProjectEffort.create(:month => 1.month.ago.month, :year => 1.month.ago.year, :sponsored_project_allocation_id => allocation.id, :current_allocation => allocation.current_allocation, :actual_allocation => allocation.current_allocation, :confirmed => false) end |
Instance Method Details
#unique_month_year_allocation_id? ⇒ Boolean
9 10 11 12 13 14 |
# File 'app/models/sponsored_project_effort.rb', line 9 def unique_month_year_allocation_id? duplicate = SponsoredProjectEffort.find_by_month_and_year_and_sponsored_project_allocation_id(self.month, self.year, self.sponsored_project_allocation_id) unless duplicate.nil? || duplicate.id == self.id errors.add(:base, "Can't create duplicate effort for the same month, year, and allocation.") end end |