Ruby on Rails Sunday, December 26, 2010

Anyone?

2010/12/25 Fernando Leandro <fernandoleandro1991@gmail.com>
Hello guys,

Im trying to make an advanced search form, actually i did like Ryan Bates teaches in this railscast : http://railscasts.com/episodes/111-advanced-search-form

But my problem is that i dont want to save the searches in my database and i dont know how to do this...

In the railscast, there was a comment like this:

14. Karl May 26, 2008 at 23:01

For those who may not know, if you don't want to save your searches in the database, but would like all benefits of using an AR model (like validations), you can use virtual attributes:

class Search < ActiveRecord::Base
  attr_accessor :keywords, :category_id, : minimum_price, :maximum_price
  validates_presence_of :keywords
  # blah...
end

Everything works the same, just doesn't save anything. And no need for a migration or 'searches' table in db.

But i tried it, and when i put the att_accessors in my model and try to make the search, the search returns me all the produtcs.. it dont make the search..

Does anyone knows how to solve this problem?

Thanks




--
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