undefined 方法 'i18n_key' for nil:NilClass - Rails admin



我最近开始在 rails admin 工作,当我尝试在 Rails admin 中编辑模型时,我遇到了这个 500 错误。任何帮助,不胜感激。

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

蒂亚。

我的模型,

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)>'

为了缓解进一步的问题,你展示了在配置/语言环境中获得Rails Admin翻译。

将 https://github.com/sferik/rails_admin/blob/master/config/locales/rails_admin.en.yml 复制到您的配置/语言环境目录并根据您的需求进行调整。 请参阅:https://github.com/sferik/rails_admin/wiki/Translations。

最新更新