gpt4 book ai didi

ruby-on-rails-3 - Heroku 搜索损坏 - Rails 3.1

转载 作者:行者123 更新时间:2023-11-29 14:05:30 24 4
gpt4 key购买 nike

我最近将 Rails 3.1 应用程序推送到 heroku。在本地,一切正常,但在实时应用程序中,搜索功能已损坏。

型号:

def self.search(search)
if search
find(:all, :conditions => ['name LIKE ?', "%#{search}%"])
else
find(:all)
end

结束

查看:

<%= form_tag apps_path, :method => 'get', :id => "search" do %>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", :name => nil, :class => "search-button" %>
<% end %>

Controller :

def index
@apps = App.search(params[:search])
@number_of_apps = @apps.count
end

我感觉这与我的本地设置在 SQLite3 上运行而 Heroku 设置使用 PostgreSQL 这一事实有关。

感谢任何帮助。 :)

最佳答案

请注意,Postgres like 匹配是区分大小写的。尝试使用 ILIKE 而不是 LIKE

关于ruby-on-rails-3 - Heroku 搜索损坏 - Rails 3.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7333863/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com