[Rails] Validate presence before custom validation

2012-10-20 Thread Eugeni Kurtov
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 =

[Rails] Re: Validate presence before custom validation

2012-10-20 Thread Eugeni Kurtov
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

[Rails] Re: Validate presence before custom validation

2012-10-20 Thread Eugeni Kurtov
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 ==

[Rails] Re: Validate presence before custom validation

2012-10-20 Thread Eugeni Kurtov
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/.

[Rails] Select from 3 table! has_many throug

2012-10-09 Thread Eugeni Kurtov
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

[Rails] Re: Select from 3 table! has_many throug

2012-10-09 Thread Eugeni Kurtov
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