ruby on rails - Alternative for :id param -
i have resources :users
, custom_id
inside users table.
i want use link_to "user", user
method choosing custom_id
provide link field param.
my show
action inside users_controller.rb:
... @user = user.find(custom_id: params[:id]) ...
in form use:
<%= link_to @user.name, @user %>
because wrote in userscontroller:
... @user = user.find(custom_id: params[:id]) ...
Comments
Post a Comment