views:

50

answers:

1

I have a rails model called 'audioclip'. I orginally created a scaffold with a 'new' action, which I replaced with 'new_record' and 'new_upload', becasue there are two ways to attach audio to this model.

Going to /audioclips/new_record doesn't work because it takes 'new_record' as if it was an id. Instead of changing this, I was trying to just create '/record_clip' and '/upload_clip' paths.

So in my routes.db I have:

map.record_clip '/record_clip', :controller => 'audioclips', :action => 'new_record'
map.upload_clip '/upload_clip', :controller => 'audioclips', :action => 'new_upload'

When I navigate to /record_clip, I get

ActionController::MethodNotAllowed
Only get, head, post, put, and delete requests are allowed.

I'm not extremely familiar with the inner-workings of routing yet. What is the problem here? (If it helps, I have these two statements above map.resources => :audioclips

+1  A: 

Yes, your two routes are conflicting with your mapped resource (the map.resources => :audioclips bit).

If you want to continue using resources, I suggest you change that line to:

map.resources => :audioclips,
                 :new => { 
                    :new_record_clip => :post,
                    :new_upload_clip => :post }

If you want some more information, the Rails guide is incredibly helpful on this topic:

http://guides.rubyonrails.org/routing.html#adding-more-restful-actions

jerhinesmith
thanks!I ended up working off this to create the paths audioclips/new/record and audioclips/new/upload which are fine for me
Lowgain