Another option is to create a dummy model that does not inherit from ActiveRecord, then include the validations there. If you add the right methods, you can interact with it just like a normal AR model. Something like this should get you started:
class MySearchClass
include ActiveModel::Validations
validates :start_date
validates :end_date
def save
return false unless valid?
# the dates were valid, go ahead and query the recordsreturn true
end
end
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment