Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

respond_with broke (or fixed) in rails 3.0.3

#5989

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.

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

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Michael Bensoussan
    Michael Bensoussan

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

    November 17th, 2010 @ 12:33 PM

  2. Dmitry Maksimov
    Dmitry Maksimov

    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.

    December 10th, 2010 @ 02:28 PM

  3. rails
    rails
    • 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.

    March 11th, 2011 @ 12:00 AM

  4. rails
    rails
    • State changed from open to stale

    March 11th, 2011 @ 12:00 AM