更新後、rubyアプリを起動しようとすると、エラーが発生します。
undefined method `[]' for nil:NilClass
抽出されたソース(8行目あたり):
8: <% account = Account.find_mak -%>
app/models/account.rb:68:in `find_mak'
app/views/layouts/_js_api_init.html.erb:8:in `block in _app_views_layouts__js_api_init_html_erb___274999121_65047152'
app/views/layouts/_js_api_init.html.erb:1:in `_app_views_layouts__js_api_init_html_erb___274999121_65047152'
app/views/layouts/logged_out.html.erb:17:in `_app_views_layouts_logged_out_html_erb__713588534_51277824'
app/controllers/leads_controller.rb:11:in `new'
config/initializers/newrelic_instrumentation.rb:30:in `call'
config/initializers/newrelic_instrumentation.rb:51:in `call'
しかし、8行目で何が起こったのかわかりません。どうすればこのエラーをデバッグできますか?回答のためにさらに情報が必要な場合は、コメントを書いてください。ありがとう。
class Account
include Mongoid::Document
include Mongoid::Timestamps
attr_accessible :org_name, :time_zone
field :org_name
... ...
def self.find_mak
where( org_name: 'Mak' ).first
end
end
他の場所でエラーが発生しました
<%= form_tag "/apps/#{Account.find_mak.api_key}/users",
method: :post, remote: true,
'data-type' => 'json',
id: 'register',
:class => 'custom register' do %>