I have below resource route
resources :listings
This will have the path set to locahost:3000/listings/new
But how can I customise path to new action(only) to show like
locahost:3000/listings/create_your_listing
or even(better if it can be customised like this)
locahost:3000/owners/create_your_listing
Only new action of the resources should be like that and rest as normal.. How can I achieve this?
First,
resources :listings, except: :new
This will create listings
resources except new
.
next,
get "/owners/create_your_listing", to: "listings#new"
This will create the missing new
route for your listing controller
.
EDIT:
This may be the way to achieve custom path:(not tested)
scope(path_names: { new: 'create_your_listing'}) do
resources :listing, path: 'listings'
end
Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With