Redirect-related double render error in rails

ruby, ruby-on-rails

Solution

Try adding `and return` so that the action returns and does not continue. Please try the following:

redirect_to style_path(@style) and return

Problem

In my controller I am redirecting the user if they are signed out. Then I am pulling a list of professionals.. and need to redirect there too, if none exist. Is there a way to solve this dilemma? ``` def purchase @style = Style.find(params[:id]) if user_signed_in? && current_user.consumer @professionals = Professional.where(...) if @professionals.empty? redirect_to style_path(@style) else ... end ... else flash[:error] = "Please sign in as a consumer to access this page" redirect_to style_path(@style) end end ```

Original source