2
有一些「複雜的」路由,清除以下硬編碼鏈接並將它們命名爲路由會是一種好方法嗎?我在幾個地方有這些類型的構造,並希望讓它們脫離代碼。重構rails更新方法中硬編碼鏈接的最佳方式?
profiles_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