Cal Peters
Cal Peters

Reputation: 81

How can I alter url paths?

For example, because my controller is called listings, whenever I post a new listing it is for example domain.com/listings/listing-name however I would like it to be domain.com/businesses/listing-name instead.

How can I do this?

Current routes for this controller:

  resources :listings do
     member do
       post :leadcreate
       post :storycreate
     end
  end

Upvotes: 0

Views: 25

Answers (1)

usha
usha

Reputation: 29349

Use path option

resources :listings, :path => "businesses" do
end

If you also want to rename the route helpers, then

resources :listings, :path => "businesses", :as => "businesses" do
end

Upvotes: 4

Related Questions