【发布时间】:2016-05-31 08:27:41
【问题描述】:
看完 rails 演员表后:https://www.youtube.com/watch?v=u6CMY3mUv90 我试图让自己的 Rails 项目全球化,但我收到“undefiend method for translates”错误
gem 'globalize'
我在我的 bash 终端中进行了捆绑安装,并且还成功进行了捆绑更新
然后我添加了“翻译:标题,:内容”,如下所示:
class Post < ActiveRecord::Base
belongs_to :admin
has_many :comments
rails_admin do
edit do
field :title
field :content, :ck_editor
field :link_title
field :link
field :admin
end
end
translates: title, :content
结束
然后我添加了
class TranslatePosts < ActiveRecord::Migration
def self.up
Post.create_translation_table!({
:title => :string,
:text => :text
}, {
:migrate_data => true
})
end
def self.down
Post.drop_translation_table! :migrate_data => true
end
end
我确实 rake db:migrate
但我仍然得到错误。知道为什么它不工作吗?
【问题讨论】:
-
您是否尝试过像这样在 gemfile 中强制使用特定版本:
gem 'globalize', '~> 5.0.0' -
感谢您的回复!是的,我做到了。但即使我在 gemfile 中尝试了几个版本,它也不起作用。你还有其他想法吗?
标签: ruby-on-rails undefined globalization