更新アクションの後にshowアクションにリダイレクトする必要がある単純なアプリに取り組んでいます。
私はショーのためにこのルートを持っています。
match '/user/:fullname' => 'items#show'
これでこのコントローラーができました。
@user = User.find_by_fullname(params[:fullname])
ただし、ユーザーの更新方法の後、
def update
if @user.update_attributes(params[:user])
format.html { redirect_to @user } # Don't need to pass parameters here.
else
format.html { render action: 'edit' }
end
end
それは私をショーアクションの元のフォーマットにリダイレクトします:
sampleapp.dev/users/1
完全名であるroutes.rbで指定した形式を使用して、アクションを表示するようにリダイレクトするにはどうすればよいですか?
sampleapp.dev/users/johndoe