validates :place_id, :title, :level, :start_at, :end_at, :presence =
true
validate :event_takes_place_in_one_day, :event_is_not_in_past
def event_takes_place_in_one_day
self.start_at.day == self.end_at.day
end
def event_is_not_in_past
admissible_range =
cover? is the method of ActiveSupport.
Ahh yeah, I loose it:)
So what should I do - create a new inheritance from
ActiveModel::Validator for each check?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk
Sorry, English is not my native language:)
Application have a Meeting model with start_at and end_at DateTime type
attributes, which indicate a start and the end of the meeting
respectively.
I need to implement next logic
start_at end_at (that it starts after than end)
start_at.day ==
Great, according to this logic system will take care for error messages
and this will not take place, right? :)
if start_at.nil?
errors.add(:start_at, can't be blank)
return
if start_end.nil?
errors.add(:end_at, can't be blank)
return
--
Posted via http://www.ruby-forum.com/.
class Place ActiveRecord::Base
attr_accessible :address, :city, :name, :description
has_many :meetings
end
Class Meeting ActiveRecord::Base
attr_accessible :start_at, :place_id, :title, :end_at
belongs_to :place
has_many :participations
has_many :players, :through = :participations
Colin Law wrote in post #1079115:
On 9 October 2012 17:29, Eugeni Kurtov li...@ruby-forum.com wrote:
has_many :players, :through = :participations
end
class Participation ActiveRecord::Base
attr_accessible :meeting_id, :player_id
You need belongs_to metting and player here.
Sure
6 matches
Mail list logo