huginn/app/models/link.rb
Dominik Sander b2f031003f Use strong_parameters and drop protected_attributes
* Ensure admin attribute can not be set at sign up and the agents user_id is not changeable
* Remove ACCESSIBLE_ATTRIBUTES from the User model
* Remove side effect on agent_params from AgentsController#build_agent
2016-09-12 15:54:26 +02:00

11 lines
464 B
Ruby

# A Link connects Agents in a directed Event flow from the `source` to the `receiver`.
class Link < ActiveRecord::Base
belongs_to :source, :class_name => "Agent", :inverse_of => :links_as_source
belongs_to :receiver, :class_name => "Agent", :inverse_of => :links_as_receiver
before_create :store_event_id_at_creation
def store_event_id_at_creation
self.event_id_at_creation = source.events.limit(1).reorder("id desc").pluck(:id).first || 0
end
end