未定义的方法`i18n_key'为nil:NilClass - Rails admin

时间:2016-03-12 07:31:35

标签: ruby ruby-on-rails-3 rails-admin

我最近开始在rails admin工作,我收到这个500错误,当我尝试在Rails管理员中编辑模型时发生。任何帮助表示赞赏。

    config.model Order do
      edit do
       field :status do 
        label "Status"
      end
      end
    end

TIA。

我的模特,

class Order < ActiveRecord::Base

  belongs_to :customer, inverse_of: :orders
  has_many :mmso
  has_many :mmis, through: :mmso
  has_one :hm, through: :mmi
  has_one :pay
  belongs_to :delivery, inverse_of: :orders
  belongs_to :addr

错误日志以便进一步理解。

 NoMethodError - undefined method `i18n_key' for nil:NilClass:
  rails_admin (0.8.1) app/helpers/rails_admin/application_helper.rb:66:in `wording_for'
  rails_admin (0.8.1) app/views/rails_admin/main/_form_nested_one.html.haml:7:in `__home_preethi__rbenv_versions_______lib_ruby_gems_______gems_rails_admin_______app_views_rails_admin_main__form_nested_one_html_haml___1061508105842580381_47125905871900'
  actionview (4.2.4) lib/action_view/template.rb:145:in `block in render'
  activesupport (4.2.4) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.4) lib/active_support/notifications.rb:164:in `instrument'
  actionview (4.2.4) lib/action_view/template.rb:333:in `instrument'
  actionview (4.2.4) lib/action_view/template.rb:143:in `render'
  actionview (4.2.4) lib/action_view/renderer/partial_renderer.rb:339:in `render_partial'
  actionview (4.2.4) lib/action_view/renderer/partial_renderer.rb:310:in `block in render'
  actionview (4.2.4) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
  activesupport (4.2.4) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.4) lib/active_support/notifications.rb:164:in `instrument'
  actionview (4.2.4) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
  actionview (4.2.4) lib/action_view/renderer/partial_renderer.rb:309:in `render'
  actionview (4.2.4) lib/action_view/renderer/renderer.rb:47:in `render_partial'
  actionview (4.2.4) lib/action_view/renderer/renderer.rb:21:in `render'
  actionview (4.2.4) lib/action_view/helpers/rendering_helper.rb:32:in `render'
  haml (4.0.7) lib/haml/helpers/action_view_mods.rb:10:in `block in render_with_haml'
  haml (4.0.7) lib/haml/helpers.rb:89:in `non_haml'
  haml (4.0.7) lib/haml/helpers/action_view_mods.rb:10:in `render_with_haml'
  rails_admin (0.8.1) lib/rails_admin/config/fields/base.rb:220:in `block in <class:Base>'
  rails_admin (0.8.1) lib/rails_admin/config/configurable.rb:66:in `block in register_instance_option'
  rails_admin (0.8.1) lib/rails_admin/config/proxyable/proxy.rb:27:in `method_missing'
  spring (1.6.2) lib/spring/client.rb:28:in `run'
  spring (1.6.2) bin/spring:49:in `<top (required)>'
  spring (1.6.2) lib/spring/binstub.rb:11:in `<top (required)>'
  /home/preethi/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  bin/spring:13:in `<top (required)>'

1 个答案:

答案 0 :(得分:0)

为了缓解更多问题,您可以在config / locales中显示获取Rails管理员翻译。

  

https://github.com/sferik/rails_admin/blob/master/config/locales/rails_admin.en.yml复制到您的config / locales目录并根据您的需要进行调整。   请参阅:https://github.com/sferik/rails_admin/wiki/Translations