Forum: Ruby on Rails assert_redirected_to Exception occurs with RESTful applicati

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
53d4002427665db72120f3fa0714ea52?d=identicon&s=25 Ruby.Me.Silly (Guest)
on 2007-01-19 16:30
(Received via mailing list)
Let me start off by stating something really funky is going on with
posting messages to this group.  This is not the first time I've posted
a message only to find it never appears in the group listing.  Does
anyone else have this problem or does someone have it out for me?  :)

I am receiving an exception on execution of a functional test.  The
exception messages reads as:
"NoMethodError: undefined method `first' for :users:Symbol"

My routes.rb contains the entry:

map.resources :users
My users_controller.rb contains the following in the action I am

def create
    flash[:notice] = "Task was successfully created"
    redirect_to user_url(@user)
My users_controller_test.rb contains this test:

def test_create_user

    post :create,
      { :user => {
        :username => "john",
        :password => "rubycon",
        :first_name => "John",
        :last_name => "Smith" } }

    assert_equal "Task was successfully created", flash[:notice]
    assert_redirected_to :controller => :tasks

I know the logic is thin but I'm keeping it that way to resolve the
issue.  The exception is occuring on the assert_redirected_to line in
the functional test.

I would appreciate any feedback on this problem.  I've not had any luck
determining a fix from Google or discussion group searches.

70225136eacd3d870f64e03bff678655?d=identicon&s=25 Russell Norris (Guest)
on 2007-01-19 16:31
(Received via mailing list)
If you're mapping the TaskController via map.resources :tasks, you might
assert_redirected_to named_task_route. I know I've run across this
before but I really can't remember what I did to go around it. [shrugs]

This topic is locked and can not be replied to.