有一些“复杂”的路由,什么是清理硬编码链接并使其命名为路由的好方法?我在几个位置都有这种结构,并希望将它们从代码中删除。
profile_controller.rb
def update
@profile = Profile.find(params[:id])
@tags = Session.tag_counts_on(:tags)
@profile.form = params[:form]
@match = Match.where(:user_id => current_user.id).first
authorize! :update, @profile
respond_to do |format|
if @profile.update_attributes(params[:profile])
format.html { redirect_to "/me/#{ current_user.username }/edit/#{ @profile.form }", notice: t('notice.saved') }
else
format.html { render action: "/edit/edit_" + params[:profile][:form], :what => @profile.form }
end
end
end