best way to rewrite /profiles/1/edit/details towards /me/profile/details?
Im trying to namespace several routes under a "me" /me section to have all
user profile/account based stuff under this namespace for more clean
routing.
What would be the best way to approach this? I find that rewriting the
default REST routing ( profiles/1/edit ) gives several issues like forms
not updating.
Routes
get "/me/profile" => "profiles#show", :as => :my_profile
get "/me/profile/:what" => "profiles#edit", :as => :my_profile_edit
post "/me/profile/:what" => "profiles#edit"
ProfilesController
def edit
@profile = current_user.profile
if ["basics", "location", "details", "photos"].member?(params[:what])
render :action => "edit/edit_#{params[:what]}"
else
render :action => "edit/edit_basics"
end
end
def update
@profile = current_user.profile
@profile.form = params[:form]
respond_to do |format|
if @profile.update_attributes!(params[:profile])
format.html { redirect_to :back, :notice => t('notice.saved') }
else
format.html { render action => "/me/profile/" + @profile.form }
end
end
end
If feels like above is going very bad against the REST principle. How
could I achieve the wanted results in a better way?
No comments:
Post a Comment