Ruby on Rails
Tuesday, March 27, 2018
It might help to have the models for auction and user... also, I like to add the annotate gem which gives some header comments in all my models to show what fields etc are there. Very helpful info and references.
Good luck
-- you already know that the validate needs to be validates...
is this an active system or SUD? do you have a solid development database that is well populated to test/develop against?
this link may help some: http://guides.rubyonrails.org/active_record_validations.html#custom-methods
other than that I'd have to see it in action to debug further.
Good luck
Max
On Monday, March 26, 2018 at 6:17:56 PM UTC-6, fugee ohu wrote:
On Monday, March 26, 2018 at 6:17:56 PM UTC-6, 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_activeclass Bid < ActiveRecord::Basebelongs_to :auctionbelongs_to :uservalidates :auction, :user, presence: truevalidate :auction_active?, message: :auction_activevalidate :last_user_different?scope :sorted, -> { order(:created_at) }after_create :update_auctionprivatedef auction_active?if auction && !auction.active?if auction.finished?errors.add(:auction, :finished)elseerrors.add(:auction, :not_started)endendenddef last_user_different?if auction && usererrors.add(:user, :same_user_twice) if auction.last_user == userendenddef update_auctionauction.increase_price_and_time auction.publish_updatesendend
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+unsubscribe@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/88b2801f-f7d7-4c32-b81f-7180632db1d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment