rails 3.2
ruby 2.0
有一个表单可以创建或编辑民意调查:
= f.error_messages header_message: nil
= f.input :question, input_html: { class: 'input-block-level' }
= f.input :results_hidden, as: :boolean, inline_label: 'Скрыть результаты до окончания опроса', label: false
= f.input :from_date, as: :datetime, input_html: { class: 'poll_date' }
= f.input :to_date, as: :datetime, input_html: { class: 'poll_date' }
%h3#poll-items Варианты ответа (не больше пяти)
.item_index
= f.fields_for :poll_items do |poll|
= render "poll_item_fields", f: poll
.links
= link_to_add_association 'Добавить еще вариант', f, :poll_items, render_options: {class: 'links'}
polls_controller.rb
def update
if @poll.owner_type == "Post"
@post = Post.find(@poll.owner_id)
elsif @poll.owner_type == "BlogPost"
@post = BlogPost.find(@poll.owner_id)
end
binding.pry
if @poll.editable?(current_user)
if @poll.update_attributes params[:poll]
respond_to do |format|
format.html { redirect_to @post, notice: 'Опрос был успешно обновлен.' }
end
else
respond_to do |format|
format.html { render :edit, alert: @poll.errors }
end
end
end
end
当我在文章中创建或编辑民意调查时,俄语字符显示为??????????
如果我创建一篇新文章,则所有文章都会显示Cyrillic。唯一的问题是创建或编辑民意调查(民意调查)。
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: db_development
username: root
password: "123"
socket: /var/run/mysqld/mysqld.sock
我浏览了管理控制台mysql。提出请求:SELECT * FROM polls WHERE id = 13;
在application.rb中:
config.time_zone = 'Moscow'
config.i18n.locale = :ru
config.i18n.default_locale = :ru
config.encoding = "utf-8"
config.action_dispatch.default_charset = "utf-8"
我使用rake db:migrate创建了数据库,并在我的数据库中导入了sql文件
答案 0 :(得分:-1)
尝试在文件顶部添加此项
bl create