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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:48:48+00:00 2026-05-22T11:48:48+00:00

Having problems figuring this out. trying to do a rescue_from NoMethodError, :with => :try_some_options

  • 0

Having problems figuring this out.

trying to do a

rescue_from NoMethodError, :with => :try_some_options

But its not working.

EDITED:
For testing I’m doing a simple redirect

def try_some_options
 redirect_to root_url
end

EDITED 2:
Sample of my controller. Added (exception) as recommended below.

I know the reason I’m getting the error. Using Authlogic and authlogic_facebook_connect plugin. When user is created from the facebook plugin the “MyCar” model, which is associated with a user is not created like it normally is created if a user registers locally. Since I do call on the user model and reference the users car throughout different parts of the site, I would like to do something like what you see below and eventually put it in my application_controller.

class UsersController < ApplicationController
 before_filter :login_required, :except => [:new, :create]
 rescue_from NoMethodError, :with => :try_some_options

 ...

 def show
    store_target_location
    @user = current_user
  end

 def create
  @user = User.new(params[:user])
  if @user.save
    MyCar.create!(:user => @user)
    flash[:notice] = "Successfully created profile."
    redirect_to profile_path
  else
    render :action => 'new'
  end
 end
 ...

 protected

 def try_some_options(exception)
    if logged_in? && current_user.my_car.blank?
       MyCar.create!(:user => current_user)
       redirect_to_target_or_default profile_path
    end
 end
 ...
end

EDITED 3: Hacked it for now since I know why the error is showing up, but would like to figure out how to rescue_from NoMethodError

class UsersController < ApplicationController
 before_filter :login_required, :except => [:new, :create]
 before_filter :add_car_if_missing

 def add_car_if_missing
   if logged_in? && current_user.my_car.blank?
     MyCar.create!(:user => current_user)
   end
 end
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-22T11:48:49+00:00Added an answer on May 22, 2026 at 11:48 am

    I just read your post when trying to come up with a solution to the same problem. In the end I did the following:

    class ExampleController < ApplicationController
      rescue_from Exception, :with => :render_404
      ...
    
    private
    
      def render_404(exception = nil)
        logger.info "Exception, redirecting: #{exception.message}" if exception
        render(:action => :index)
      end
    end
    

    This worked well for me. It is a catch all situation yet it just may help you. All the best.

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

Sidebar

Related Questions

Having some problems figuring out the regex to match this: function Array() { [native
I'm trying to build a bbcode parser, but I'm having quite some problems figuring
Maybe I'm just thinking about this too hard, but I'm having a problem figuring
I am still having problems with figuring out how to create winforms in a
I'm having problems figuring out how to display different cell styles as well as
Im having problems displaying records to my view when passing viewdata to a user
Im having problems building a query with the linq to sql data query expression
I have recently started having problems with TortoiseCVS, or more specifically with plink, the
I'm having problems using textures that are larger than the OpenGL window or the
I'm having problems deciding on what is the best way is to handle and

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.