Sunday, 15 February 2015

ruby on rails - How to escape this redirect loop? -



ruby on rails - How to escape this redirect loop? -

i'm trying create user's illicit attempts see other users' show page redirect instead own show page.

none of attempts in else section of code job though.

class userscontroller < applicationcontroller def show if params[:id] == current_user.id.to_s liked_bookmark_ids = current_user.likes.pluck(:bookmark_id) liked_bookmarks = bookmark.where(id:liked_bookmark_ids) liked_topic_ids = liked_bookmarks.pluck(:topic_id) @liked_topics = topic.where(id:liked_topic_ids).order('topics.name') else # redirect_to :controller => 'users', :id => current_user.id # gives screwy url # redirect_to user_path, :id => 6 # causes redirect loop # redirect_to :back # causes redirect loop end end end

what's right way go it?

redirect_to user_path(current_user)

ruby-on-rails

No comments:

Post a Comment