When creating a model function does it get seen to the controller?
I have a model present and i have the following function
before_create :check_exists
attr_accessible :customer_id, :event_id
#RELATIONSHIP
belongs_to :customer
belongs_to :event
private
def check_exists
present = Present.find_or_create_by_customer_id_and_event_id(:customer.id => current_customer.id, :event_id => self.event_id)
end
How do I know that self.event_id is being use properly, how do i call this resource properly
Yes, the method can be accessed through controllers.
:customer_idand:event_idare supposed to be both properties of the model instance, so they will be used accordingly within your method. All you have to do is callcheck_existsfrom anyPresentinstance (not thePresentclass, for this is not declared as static method).Luck.