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.

Unclear route error thrown when an invalid object is passed to a "_path" method

#6224

Assuming that we have the following resources at config/routes.rb:

... resources :users do
reousrces :posts end
...

So, somewhere in a view, I would use the link_to method:

link_to 'Go!', user_posts_path(@anything)

Assuming that the @anything is invalid, Rails throws a very unclear error about the route:

"ActionController::RoutingError in Welcome#index"

In my opinion, it should first throw an error saying that the passed parameter is not valid, because the route exists, but only the parameter is invalid.

I can provide further details for you to reproduce this scenario.

Reported by Hiram Nascimento · December 26th, 2010 @ 04:54 PM

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

Activity

  1. Andrew White
    Andrew White
    • State changed from new to needs-more-info
    • Importance changed from to Low

    What do you mean by invalid? Do you mean that it's an instance of User but @user.valid? is false? Can you please post a backtrace, thanks.

    February 9th, 2011 @ 04:28 AM

  2. Andrew White
    Andrew White
    • State changed from needs-more-info to stale

    Marking as stale as no feedback for a month

    March 6th, 2011 @ 04:28 PM