bdeonovic
bdeonovic

Reputation: 4220

Rails: redirection problems

I don't want people to be able to go to /cvit so I had it redirected like so in routes.rb

match '/cvit' => redirect("/cvit/new")

but this causes a problem because you cannot get to /cvit/51 (a results page) because it would also redirect that to /cvit/new. How can I get around this??? Thanks

Upvotes: 0

Views: 51

Answers (2)

apneadiving
apneadiving

Reputation: 115511

I'd have done:

resources :cvits, :path => 'cvit' do
  get 'new' , :on => :collection
end

Upvotes: 1

fl00r
fl00r

Reputation: 83680

mmmmm I thought it should work fine. Then try this:

match '/:cvit' => redirect("/cvit/new"), :constraints => { :cvit => "cvit" }

Upvotes: 1

Related Questions