This project is archived and is in readonly mode.

#5989 ✓stale
Edgar Suarez

respond_with broke (or fixed) in rails 3.0.3

Reported by Edgar Suarez | November 16th, 2010 @ 09:48 PM

I'm using rails 3.0.1, with responders gem. I had this code in my controllers:

respond_with(:location => root_path, :status => :ok)

This is since I only need to handle response's status on an ajax call, I don't need to respond with a resource.

However when updating to rails 3.0.3 it just broke that code by throwing error: undefined method 'model_name' for NilClass:Class

This is of course, as Jose Valim says, because respond_with accepts only a resource as argument, but I think in some cases you just want a shortcut to respond with a proper status or headers.

I'm willing to submit a patch for this, but for now I'm too busy. I'm opening this ticket so if anyone else wants to take it.

Comments and changes to this ticket

  • Michael Bensoussan

    Michael Bensoussan November 17th, 2010 @ 12:33 PM

    got the same issue, I'll try to submit a patch if I find some time

  • Dmitry Maksimov

    Dmitry Maksimov December 10th, 2010 @ 02:28 PM

    As temporary solution you can pass empty hash as first parameter:

      respond_with({}, :location => root_path, :status => :ok)

    Changes that lead to this error were made by commit d4b7fa5fb6b4aee8dee90b526c08c0dd2e5e97d3.

  • rails

    rails March 11th, 2011 @ 12:00 AM

    • Tag changed from 3.0.1, 3.0.3, controllers, responders, respond_with to 301, 303, controllers, responders, respond_with
    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • rails

    rails March 11th, 2011 @ 12:00 AM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>