Ruby 2.1 sqlite 3
我可以从数据库中写入和读取数据,但无法搜索。 视图中有一个搜索字段,提交时有
Encoding::CompatibilityError in AdvertisementsController
incompatible character encodings: ASCII-8BIT and UTF-8
但是日志中的参数是
{"utf8"=>"✓",
"search"=>"essai"}
“essai”是搜索字段中的单词。
view.erb
<%= form_tag advertisements_path, method: :get do %>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", name: nil %>
<% end %>
advertisements_controller.rb
def index
if params[:search]
@advertisements = Advertisement.find(:all, :conditions => [' name LIKE ? or content LIKE ?', "%#{params[:search]}%", "%#{params[:search]}%" ])
else
@advertisements = @advertisements.published.
include_associations.page(params[:page])
end
end
怎么了?