Ruby on Rails NoMethodError“未定义的方法`翻译'”

时间:2014-12-19 17:28:18

标签: ruby-on-rails ruby ruby-on-rails-3 gem globalize3

我在本地的应用程序运行良好,但是当我推送服务器时它崩溃了这个错误:

`NoMethodError in PagesController#index

undefined method `translates' for #<Class:0x0000000339e880>`

它可能是由globalize3 gem引起的,但我安装了一些我在其他问题中找到的宝石并没有解决我的问题。 我安装了:

- gem 'globalize', '~> 3.1.0' 
- gem 'globalize-accessors'
- gem 'globalize3_helpers'
- gem "friendly_id"
- gem 'i18n', '~> 0.6.1'
- gem 'batch_translations', '~> 0.1.3'

这是我服务器中的gem文件:

source 'https://rubygems.org'

gem 'rails', '3.2.13'
gem 'pg'
gem 'json'
gem 'acts_as_list'

gem 'haml'
gem 'haml-rails'
gem 'jquery-rails'
gem 'jquery-ui-rails'

gem 'globalize3', '0.2.0.beta8'
gem 'remotipart'
gem 'rabl'

gem 'carrierwave'

gem 'awesome_nested_set' # or any similar gem (gem 'nested_set')
gem "the_sortable_tree", "~> 2.5.0"

gem 'bcrypt-ruby', '~> 3.0.0'

gem 'will_paginate'

gem 'browser'

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'uglifier', '>= 1.0.3'
end

gem 'coffee-rails', '~> 3.2.1'


group :development do
  gem 'better_errors'
  gem 'binding_of_caller'
  gem "rails-erd"
  gem 'pry-rails'
  gem 'awesome_print'
  gem 'debugger'
  gem 'annotate', ">=2.5.0"
  gem 'yard'
  gem 'redcarpet'
end  

group :development, :test do
  gem 'rspec-rails'
  gem 'factory_girl_rails'
  gem 'rb-fsevent', '~> 0.9.1'
  gem 'launchy'
  gem "spork"
  gem "guard-spork"
  gem 'guard-rspec'
  gem 'terminal-notifier-guard'
  gem 'poltergeist'
end

这是我服务器中的gemfile:

source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'pg', '=0.14.1' 
gem 'json'
gem 'acts_as_list'

gem 'haml'
gem 'haml-rails'
gem 'jquery-rails'
gem 'jquery-ui-rails'

gem 'globalize3'
gem 'globalize3_helpers'
gem "friendly_id"
gem 'i18n', '~> 0.6.1'
gem 'batch_translations', '~> 0.1.3' 
gem 'remotipart'
gem 'rabl'

gem 'carrierwave'
gem 'awesome_nested_set'
gem "the_sortable_tree", "~> 2.5.0"

gem 'bcrypt-ruby', '~> 3.0.0'

gem 'will_paginate'

gem 'browser'

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'uglifier', '>= 1.0.3'
end

gem 'coffee-rails', '~> 3.2.1'


group :development do
  gem 'better_errors'
  gem 'binding_of_caller'
  #gem 'capistrano-unicorn'
  gem "rails-erd"
  gem 'pry-rails'
  gem 'awesome_print'
  gem 'annotate', ">=2.5.0"
  gem 'yard'
  #gem 'redcarpet'
end  

group :development, :test do
  gem 'rspec-rails'
  gem 'factory_girl_rails'
  gem 'rb-fsevent', '~> 0.9.1'
  gem 'launchy'
  gem "spork"
  gem "guard-spork"
  gem 'guard-rspec'
  gem 'terminal-notifier-guard'
  gem 'poltergeist'
end

我在本地服务器上的宝石列表:

*** LOCAL GEMS ***

actionmailer (4.1.8, 4.1.6, 3.2.13, 3.2.8, 3.2.2)
actionpack (4.1.8, 4.1.6, 3.2.13, 3.2.8, 3.2.2)
actionview (4.1.8, 4.1.6)
activemodel (4.1.8, 4.1.6, 3.2.13, 3.2.8, 3.2.2)
activerecord (4.1.8, 4.1.6, 3.2.13, 3.2.8, 3.2.2)
activerecord-postgres-hstore (0.5.3)
activeresource (3.2.13, 3.2.8, 3.2.2)
activesupport (4.1.8, 4.1.6, 3.2.13, 3.2.8, 3.2.2)
acts_as_list (0.5.0, 0.1.8)
addressable (2.3.6, 2.3.2)
annotate (2.6.5, 2.5.0)
apartment (0.25.2)
arel (5.0.1.20140414130214, 3.0.3, 3.0.2)
Ascii85 (1.0.2)
autoprefixer-rails (4.0.1.1)
awesome_nested_set (2.1.6, 2.1.4)
awesome_print (1.2.0, 1.1.0)
barby (0.5.0)
batch_translations (0.1.3)
bcrypt (3.1.9)
bcrypt-ruby (3.0.1)
best_in_place (2.0.2)
better_errors (2.0.0, 0.3.2)
bigdecimal (1.2.4)
binding_of_caller (0.7.2)
bootstrap-sass (3.3.1.0)
browser (0.8.0, 0.1.5)
builder (3.2.2, 3.0.4, 3.0.3)
bundler (1.7.3)
bundler-unload (1.0.2)
cancan (1.6.8)
capistrano (2.15.5, 2.13.5)
capybara (2.4.4)
carrierwave (0.10.0, 0.7.1)
celluloid (0.16.0)
childprocess (0.5.5)
choice (0.1.6)
cliver (0.3.2)
coderay (1.1.0, 1.0.7)
coffee-rails (4.1.0, 3.2.2)
coffee-script (2.3.0, 2.2.0)
coffee-script-source (1.8.0, 1.4.0, 1.3.3)
columnize (0.9.0, 0.8.9)
database_cleaner (1.3.0)
debug_inspector (0.0.2)
debugger (1.6.8)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.3.7)
devise (3.4.1)
diff-lcs (1.2.5)
erubis (2.7.0)
exception_notification (3.0.1)
execjs (2.2.2, 1.4.0)
executable-hooks (1.3.2)
factory_girl (4.5.0)
factory_girl_rails (4.5.0)
faker (1.4.3)
faraday (0.8.4)
ffi (1.9.6)
formatador (0.2.5)
friendly_id (4.0.10.1)
gem-wrappers (1.2.5)
globalize (3.1.0)
globalize-accessors (0.1.5)
globalize3 (0.2.0.beta8)
globalize3_helpers (0.3.0)
guard (2.10.4, 2.9.0, 2.8.2, 1.8.3)
guard-compat (1.1.0, 0.3.0)
guard-rspec (4.5.0, 4.4.2, 4.3.1, 3.1.0)
guard-spork (2.1.0, 2.0.2, 2.0.1, 1.5.2)
haml (4.1.0.beta.1, 4.0.6)
haml-rails (0.6.0, 0.4)
hashery (2.1.0)
highline (1.6.21, 1.6.16, 1.6.15)
hike (1.2.3, 1.2.1)
hitimes (1.2.2)
hpricot (0.8.6)
html2haml (1.0.1)
httpauth (0.2.0)
i18n (0.7.0.beta1, 0.6.11, 0.6.1)
io-console (0.4.2)
journey (1.0.4)
jquery-datatables-rails (2.2.2)
jquery-migrate-rails (1.2.1)
jquery-rails (3.1.2, 2.3.0, 2.1.4, 2.1.2)
jquery-ui-rails (5.0.3, 4.1.2, 2.0.2)
json (1.8.1, 1.7.5)
kgio (2.9.2, 2.7.4)
launchy (2.4.3)
listen (2.8.3, 2.8.2, 2.8.1, 1.3.1)
lumberjack (1.0.9)
mail (2.6.3, 2.6.1, 2.5.4, 2.4.4)
method_source (0.8.2)
mime-types (2.4.3, 2.3, 1.25.1, 1.23, 1.19)
mini_portile (0.6.1)
minitest (5.5.0, 5.4.2, 4.7.5)
multi_json (1.10.1, 1.7.7, 1.4.0, 1.3.6)
multipart-post (1.1.5)
nenv (0.1.1)
nestedsortabletree-rails (0.1.2.1)
net-scp (1.2.1, 1.1.0, 1.0.4)
net-sftp (2.1.2, 2.1.1, 2.0.5)
net-ssh (2.9.1, 2.6.6, 2.6.2)
net-ssh-gateway (1.2.0, 1.1.0)
nokogiri (1.6.5, 1.6.4.1)
oauth (0.4.7)
oauth2 (0.6.1)
orm_adapter (0.5.0)
paper_trail (2.7.2)
pdf-reader (1.2.0)
pg (0.17.1, 0.14.1)
poltergeist (1.5.1)
polyglot (0.3.5, 0.3.3)
prawn (0.12.0)
prawn-svg (0.12.0.3)
pry (0.10.1)
pry-rails (0.3.2)
psych (2.0.3)
quiet_assets (1.0.3)
rabl (0.11.5, 0.11.4)
rack (1.5.2, 1.4.5, 1.4.1)
rack-cache (1.2)
rack-ssl (1.3.4, 1.3.2)
rack-test (0.6.2, 0.6.1)
rails (4.1.8, 4.1.6, 3.2.13, 3.2.8, 3.2.2)
rails-api (0.3.1, 0.0.3, 0.0.2)
rails-erd (1.1.0)
railties (4.1.8, 4.1.6, 3.2.13, 3.2.8, 3.2.2)
raindrops (0.13.0, 0.10.0)
rake (10.4.2, 10.4.0, 10.3.2, 10.1.0, 10.0.4, 10.0.2, 0.9.2.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
rb-kqueue (0.2.3)
rb-readline (0.4.2)
rdoc (4.1.0, 3.12.2, 3.12)
redactor-rails (0.4.5)
redcarpet (3.2.2, 3.2.1, 3.2.0)
remotipart (1.2.1)
responders (1.1.2)
rmagick (2.13.4, 2.13.3, 2.13.1)
rspec (3.1.0, 2.99.0)
rspec-collection_matchers (1.1.2)
rspec-core (3.1.7, 2.99.2)
rspec-expectations (3.1.2, 2.99.2)
rspec-mocks (3.1.3, 2.99.2)
rspec-rails (3.1.0, 2.99.0)
rspec-support (3.1.2)
ruby-graphviz (1.0.9)
ruby-rc4 (0.1.5)
ruby_parser (3.1.3)
rubygems-bundler (1.4.4)
rubyzip (1.1.6)
rvm (1.11.3.9)
sass (3.4.9, 3.4.8, 3.2.3, 3.2.1)
sass-rails (5.0.0, 3.2.6, 3.2.5)
selenium-webdriver (2.44.0)
sexp_processor (4.4.4)
slop (3.6.0)
sorcery (0.7.13)
spork (0.9.2)
sprockets (2.12.3, 2.12.2, 2.2.3, 2.2.2, 2.1.4, 2.1.3)
sprockets-rails (2.2.2, 2.1.4)
sqlite3 (1.3.10)
state_machine (1.1.2)
superfish-rails (1.6.0.1)
terminal-notifier-guard (1.6.4)
test-unit (2.1.1.0)
the_sortable_tree (2.5.0)
thor (0.19.1, 0.16.0, 0.14.6)
thread_safe (0.3.4)
tilt (1.4.1, 1.3.3)
timers (4.0.1)
treetop (1.4.15, 1.4.14, 1.4.12, 1.4.10)
ttfunk (1.0.3)
tzinfo (1.2.2, 0.3.42, 0.3.37, 0.3.35, 0.3.33)
uglifier (2.6.0, 2.5.3, 1.3.0)
unicorn (4.4.0)
warden (1.2.3)
websocket (1.2.1)
websocket-driver (0.5.0, 0.4.0)
websocket-extensions (0.1.1)
will_paginate (3.0.7, 3.0.3)
xpath (2.0.0)
yard (0.8.7.6)

我的Gem列表在服务器上:

actionmailer (4.1.0, 3.2.13, 3.2.8)
actionpack (4.1.0, 3.2.13, 3.2.8)
actionview (4.1.0)
activemodel (4.1.0, 3.2.13, 3.2.8)
activerecord (4.1.0, 3.2.13, 3.2.8)
activerecord-postgres-hstore (0.5.3)
activeresource (3.2.13, 3.2.8)
activesupport (4.1.0, 3.2.13, 3.2.8)
acts_as_list (0.5.0)
addressable (2.3.6, 2.3.2)
annotate (2.6.5)
arel (5.0.1.20140414130214, 3.0.3, 3.0.2)
Ascii85 (1.0.2)
autoprefixer-rails (4.0.1.1)
awesome_nested_set (2.1.6, 2.1.4)
awesome_print (1.2.0, 1.1.0)
barby (0.5.0)
batch_translations (0.1.3)
bcrypt-ruby (3.0.1)
best_in_place (2.0.2)
better_errors (2.0.0)
bigdecimal (1.2.4)
binding_of_caller (0.7.2)
browser (0.8.0, 0.1.5)
builder (3.2.2, 3.0.4)
bullet (4.2.0)
bundler (1.6.2)
cancan (1.6.8)
capistrano (2.15.5, 2.13.5)
capybara (2.4.4, 2.0.1)
carrierwave (0.10.0, 0.7.1)
celluloid (0.16.0)
childprocess (0.5.5, 0.3.6)
choice (0.1.6)
cliver (0.3.2)
coderay (1.1.0, 1.0.8)
coffee-rails (4.0.1, 3.2.2)
coffee-script (2.3.0, 2.2.0)
coffee-script-source (1.8.0, 1.7.1, 1.7.0, 1.4.0, 1.3.3)
columnize (0.9.0, 0.8.9)
daemon_controller (1.2.0)
database_cleaner (0.9.1)
debug_inspector (0.0.2)
debugger (1.6.8)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.3.7)
diff-lcs (1.2.5)
erubis (2.7.0)
exception_notification (3.0.1)
execjs (2.2.2, 2.2.1, 2.2.0, 1.4.0)
factory_girl (4.5.0)
factory_girl_rails (4.5.0)
faraday (0.8.4)
ffi (1.9.6, 1.2.0)
formatador (0.2.5)
friendly_id (4.0.10.1)
globalize (3.1.0)
globalize-accessors (0.1.5)
globalize3 (0.3.1, 0.2.0.beta8)
globalize3_helpers (0.3.0)
guard (2.10.4, 2.9.0, 1.5.4)
guard-compat (1.1.0)
guard-rspec (4.5.0, 4.3.1)
guard-spork (2.1.0, 2.0.2)
guard-test (0.7.0)
haml (4.0.6)
haml-rails (0.4)
hashery (2.1.0)
highline (1.6.21, 1.6.16, 1.6.15)
hike (1.2.3, 1.2.1)
hitimes (1.2.2)
httpauth (0.2.0)
i18n (0.6.11, 0.6.9, 0.6.1)
io-console (0.4.2)
jbuilder (2.2.5, 2.2.4, 2.2.3, 2.2.2, 2.2.0, 2.1.3, 2.1.2, 2.1.1, 2.1.0)
journey (1.0.4)
jquery-migrate-rails (1.2.1)
jquery-rails (3.1.2, 3.1.1, 3.1.0, 2.1.4)
jquery-ui-rails (4.1.2, 2.0.2)
json (1.8.1, 1.7.5)
kgio (2.9.2, 2.7.4, 2.0.0)
launchy (2.4.3, 2.1.2)
letter_opener (1.0.0)
libwebsocket (0.1.7.1)
listen (2.8.4, 2.8.3, 0.6.0)
lumberjack (1.0.9, 1.0.2)
mail (2.5.4, 2.4.4)
metaclass (0.0.1)
method_source (0.8.2, 0.8.1)
mime-types (1.25.1, 1.19)
mini_portile (0.6.1)
minitest (5.4.3, 5.4.2, 5.4.1, 5.4.0, 5.3.5, 5.3.4, 5.3.3, 4.7.5)
mocha (0.13.1)
multi_json (1.10.1, 1.9.3, 1.4.0)
multipart-post (1.1.5)
nenv (0.1.1)
net-scp (1.2.1, 1.1.0, 1.0.4)
net-sftp (2.1.2, 2.1.1, 2.0.5)
net-ssh (2.9.1, 2.6.6, 2.6.2)
net-ssh-gateway (1.2.0, 1.1.0)
nokogiri (1.6.5, 1.5.5)
oauth (0.4.7)
oauth2 (0.6.1)
paper_trail (2.7.2)
passenger (4.0.41)
pdf-reader (1.2.0)
pg (0.17.1, 0.14.1)
poltergeist (1.5.1)
polyglot (0.3.5, 0.3.4, 0.3.3)
prawn (0.12.0)
prawn-svg (0.12.0.3)
pry (0.10.1, 0.9.10)
pry-rails (0.3.2, 0.2.2)
psych (2.0.3)
rabl (0.11.5, 0.11.4)
rack (1.5.2, 1.4.5, 1.4.1)
rack-cache (1.2)
rack-ssl (1.3.4, 1.3.2)
rack-test (0.6.2)
rails (4.1.0, 3.2.13, 3.2.8)
rails-api (0.3.1)
rails-erd (1.2.1, 1.1.0, 1.0.0)
railties (4.1.0, 3.2.13, 3.2.8)
raindrops (0.13.0, 0.10.0)
rake (10.4.2, 10.3.2, 10.1.0, 10.0.2)
rb-fsevent (0.9.4, 0.9.2)
rb-inotify (0.9.5)
rb-readline (0.4.2)
rdoc (4.1.2, 4.1.1, 4.1.0, 3.12.2, 3.12)
redcarpet (3.2.2, 3.2.1)
remotipart (1.2.1)
rspec (3.1.0)
rspec-core (3.1.7)
rspec-expectations (3.1.2)
rspec-mocks (3.1.3)
rspec-rails (3.1.0)
rspec-support (3.1.2)
ruby-graphviz (1.0.9, 1.0.8)
ruby-rc4 (0.1.5)
rubyzip (0.9.9)
sass (3.4.9, 3.2.19, 3.2.3, 3.2.1)
sass-rails (4.0.5, 4.0.4, 4.0.3, 3.2.6, 3.2.5)
sdoc (0.4.1, 0.4.0)
selenium-webdriver (2.27.0)
slop (3.6.0, 3.3.3)
sorcery (0.7.13)
spork (0.9.2)
spring (1.2.0, 1.1.3)
sprockets (2.12.3, 2.12.1, 2.11.3, 2.11.0, 2.2.3, 2.1.4, 2.1.3)
sprockets-rails (2.2.2, 2.2.0, 2.1.4, 2.1.3)
sqlite3 (1.3.10, 1.3.9)
state_machine (1.1.2)
superfish-rails (1.6.0.1)
terminal-notifier-guard (1.6.4)
test-unit (2.5.3, 2.1.1.0)
the_sortable_tree (2.5.0, 1.9.4)
thor (0.19.1, 0.16.0)
thread_safe (0.3.4, 0.3.3)
tilt (1.4.1, 1.3.3)
timers (4.0.1)
treetop (1.4.15, 1.4.12)
ttfunk (1.0.3)
turbolinks (2.5.2, 2.5.1, 2.4.0, 2.3.0, 2.2.2)
tzinfo (1.2.2, 1.2.1, 1.1.0, 0.3.42, 0.3.35)
uglifier (2.6.0, 2.5.3, 2.5.1, 1.3.0)
unicorn (4.4.0)
uniform_notifier (1.1.0)
websocket (1.0.4)
websocket-driver (0.5.1, 0.5.0, 0.4.0)
websocket-extensions (0.1.1)
will_paginate (3.0.7, 3.0.3)
xpath (2.0.0, 1.0.0)
yard (0.8.7.6, 0.8.3)

也许是application.rb中的一个gem或一些配置?

谢谢!

1 个答案:

答案 0 :(得分:0)

Gemfile设计为在所有环境中相同,然后使用与group :development ...上的组相同的基于env加载不同的gem。也就是说,您可能在两个环境中使用不同版本的gem。

看看两个版本0.2.0.beta8和0.3.1之间的差异,您可以看到translates仍然存在,但是添加它的设置可能已更改https://github.com/globalize/globalize/compare/v0.2.0.beta8...v0.3.1#diff-a4e451ff8babf2969ff95b0205af6dd1L4

尝试修复服务器Gemfile上的版本(虽然你真的应该在prod和dev中都有相同的文件)