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 6991771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:32:49+00:00 2026-05-27T19:32:49+00:00

Where should I start looking? Here’s what makes me believe that: 0 urzatron work/secret_project

  • 0

Where should I start looking? Here’s what makes me believe that:

0 urzatron work/secret_project % rails c
Loading development environment (Rails 3.1.3)

irb(main):001:0> t = Tag.new(:name => "!Blark!")
=> #<Tag id: nil, name: "!Blark!", created_at: nil, updated_at: nil>

irb(main):002:0> t.try(:name)
=> "!Blark!"

irb(main):003:0> t.try(:aoeu)
NoMethodError: undefined method `aoeu' for #<Tag id: nil, name: "!Blark!", created_at: nil, updated_at: nil>
        from /usr/lib/ruby/gems/1.9.1/gems/activemodel-3.1.3/lib/active_model/attribute_methods.rb:385:in `method_missing'
        from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/attribute_methods.rb:60:in `method_missing'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/core_ext/object/try.rb:32:in `try'
        from (irb):3
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands/console.rb:45:in `start'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands/console.rb:8:in `start'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:40:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

The Tag model:

class Tag < ActiveRecord::Base
  has_many :taggings, :dependent => :destroy
end
  • 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-05-27T19:32:50+00:00Added an answer on May 27, 2026 at 7:32 pm

    You’re misunderstanding what try does. From the fine manual:

    try(*a, &b)
    Invokes the method identified by the symbol method, passing it any arguments and/or the block specified, just like the regular Ruby Object#send does.

    Unlike that method however, a NoMethodError exception will not be raised and nil will be returned instead, if the receiving object is a nil object or NilClass.

    So doing this:

    t.try(:aoeu)
    

    is more or less the same as this:

    t.nil?? nil : t.aoeu
    

    but you seem to be expecting it to behave like this:

    t.respond_to?(:aoeu) ? t.aoeu : nil
    

    Your t isn’t nil so t.try(:aoeu) is the same as t.aoeu. Your Tag class doesn’t have an aoeu method so you get a NoMethodError.

    try is just a convenient way of avoiding a nil check, it isn’t a way to avoid a NoMethodError when the object doesn’t respond to the method you’re trying to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the code: http://jsfiddle.net/VW8V5/1/ When hover it should start looping but end of
i have uitextfield i wan that it should start entering text from top instead
I read a lot of posts that convinced me I should start writing unit
So any custom data attribute that I use should start with data-: <li class=user
I need to verify in php that a string should not start or end
First, I should start out by admitting that I really don't know a lot
I'm looking for a voting system that we can implement at work amongst our
I am looking at the DFS pseudocode here dfs(node start) { stack s; s.push(start);
Novice Programmer here - I have an application with two threads that I start,
I am coding a game which should start several mini-games when scanning a specific

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.