On Monday, March 26, 2018 at 8:17:56 PM UTC-4, fugee ohu wrote:
>
> This model has some errors that I wasn't able to get sorted out the two 
> lines that begin with validate should be validates but after that I don't 
> understand what the author's trying to do If I change them to validates I 
> get the error Unknown validator: 'MessageValidator' for   validate 
> :auction_active?, message: :auction_active
>
>
> class Bid < ActiveRecord::Base
>   belongs_to :auction
>   belongs_to :user
>
>   validates :auction, :user, presence: true
>   validate :auction_active?, message: :auction_active
>   validate :last_user_different?
>
>   scope :sorted, -> { order(:created_at) }
>
>   after_create :update_auction
>
>   private
>
>   def auction_active?
>     if auction && !auction.active?
>       if auction.finished?
>         errors.add(:auction, :finished)
>       else
>         errors.add(:auction, :not_started)
>       end
>     end
>   end
>
>   def last_user_different?
>     if auction && user
>       errors.add(:user, :same_user_twice) if auction.last_user == user
>     end
>   end
>
>   def update_auction
>     auction.increase_price_and_time
>     auction.publish_updates
>   end
> end
>
>
Like I said I don't understand what the author's trying to do No i'm not 
using any debug tools

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/150abfed-8f4d-4df6-8a47-ea7dec132a98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to