chell
chell

Reputation: 7866

Wildcard search not working on Heroku

I have the following method in my model:

 #find all the manufacturers names and ids or those matching a search string
  def self.find_all(manufacturer="")
       m_name =  manufacturer.gsub(" ", '%') if manufacturer
    find(:all, :select => 'id, name', :order => "name", :conditions => ["name like ?", "%#{m_name.capitalize}%"])
  end

This works perfectly on my local machine, but when I put it on Heroku it works less well: if I do a search and enter more than one word it won't return any values.

What is different about Heroku?

Upvotes: 0

Views: 372

Answers (2)

Hishalv
Hishalv

Reputation: 3052

i think it has something to do with the "Like" statement. mysql and heroku's postgresql sometime needs code modifications when switching between the two.

maybe try

"name ILIKE ?"

also checkout this answer here. Always best to use same database in development and production.

Upvotes: 1

David
David

Reputation: 844

Two thoughts. Firstly, try running it in production mode locally:

rails server -e production

Also it may be that your remote database is very different to your local one.

Make sure you have done

rake db:migrate

You could optionally also do

rake db:push 

(see http://devcenter.heroku.com/articles/taps for more info)

Upvotes: 1

Related Questions