Reputation: 1771
Is it possible to use conditional statements in a Rails Model?
I'm thinking something like this:
if create
before_save do
self.position = self.track.position
end
else
acts_as_list :scope => :product_id
end
I basically want acts_as_list to be effective after the initial create has been done.
Upvotes: 0
Views: 111
Reputation: 16064
It looks like you're looking for before_create.
class Model < ActiveRecord::Base
acts_as_list :scope => :product_id
before_create :set_initial_position
private
def set_initial_position
self.position = self.track.position
end
end
Upvotes: 3