views:

14

answers:

1

I created a new action called "asked". asked.haml is in views/questions as it should be. I've also added

  def asked
    respond_to do |format|
      format.html 
      format.xml  { render :xml => @questions }
    end
  end

to the Questions controller for this action.

My problem is that when I got to the url http://localhost:3000/questions/asked, I get this error:

ActiveRecord::RecordNotFound in QuestionsController#show

Couldn't find Question with ID=asked

So, I Googled this and found out that I needed to change the way I route things.

I tried: map.connect ':controller/asked', :action => 'asked' and map.resources :questions, :collection => {:asked => :get}, but to no avail.

Obviously I don't fully understand how Rails mapping works, but if someone would let me know what's going on, I'd really appreciate it!

+1  A: 

Rails routing works by picking the first route that matches the requested URL.

From your description it seems that you put your map.connect statements to the bottom of your routes.rb. You should place it before map.resources :questions, since otherwise the URL /questions/asked is matched by map.resources as a show action.

Pavel Shved
Thank you SO MUCH!
Teef L