after we create an new entry the standard redirect is everytime to the :id. how can i change it to an own_key.
We have designed our routes
resources :lists
match '/:own_key' => 'lists/show'
If we create an new entry the redirect go to /list/:id
Is there a way to change it to redirect to own_key?
def create
@list = List.new(params[:list])
@list = List.create!(params[:list])
respond_with(@list)
end
Each model has a method called
to_paramwhich you can overridelist.rb
This will make that the path changes from
/:id, to/:own_key.NOTE: This will change only the value of the parameter but not the name of the parameter.
Example: If you want to acces with an
own_keyvalue offoothe show action/lists/foothere will not be aparams[:own_key]. You can access theown_keyvalue by withparams[:id]but not withparams[:own_key]