Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8353587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:18:31+00:00 2026-06-09T09:18:31+00:00

After update, when I try to start my ruby app, I have an error:

  • 0

After update, when I try to start my ruby app, I have an error:

undefined method `[]' for nil:NilClass

Extracted source (around line #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'

but, I dont understand what was happened on line 8, how I can debuging this error?. If you need more information for answer, please write a comment.
Thanks.

  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

now error in other place

<%= form_tag "/apps/#{Account.find_mak.api_key}/users",
               method: :post, remote: true,
               'data-type' => 'json',
               id: 'register',
               :class => 'custom register' do %>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:18:33+00:00Added an answer on June 9, 2026 at 9:18 am

    This bit in your view:

    Account.find_mak.api_key
    

    will result in the error you see if

     Account.find_mak
    

    returns nil, which it will if no matching record exists in your database.

    My suggestion would be to not use #{Account.find_mak.api_key} directly in the view, but assign it to a variable in the controller, which you can then check for nil:

    def some_action
      @account = Account.find_mak
      if @account.nil?
        # handle this case, i.e. a redirect to 404
      end
    end  
    

    Then in your view, you can use the variable and be certain it cannot be nil:

    <%= form_tag "/apps/#{@accpunt.api_key}/users", #...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After update our iphone app can not access the keychain. The distribution certificate has
If I raise an error in an AFTER UPDATE trigger in Sql Server 2005,
I have a table which is updated with ajax and after update it if
I have a listview which has its datasource changed after update of a search
Update: After playing around with this for a few hours, went with a multi-query
When I try to deploy my app with capistrano, I'll get this error: failed:
I'm trying to write an after update trigger that does a batch update on
UPDATE: After searching a bit I don't seem to be alone about this problem:
UPDATE: After updating to stylus 0.7.4 and express 2.3.12 I can no longer reproduce
Update: After some more reading I see that this problem is totally general, you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.