title: Controller redirect to different paths depending on previous page
body: <p>Question:</p>
  
  <p>How I want to redirect to different path after <code>create</code> action, given if previous_page is <code>../reader/new</code> goes to <code>../reader/blog/:id</code>, whereas if previous_page is <code>../editor/new</code> goes to <code>../editor/blog/:id</code>.</p>
  
  <p>Explaination:</p>
  
  <p>I want to modify the controller actions so that it can redirect to different path depending on which page it comes from. For example, I have a <code>reader</code>, <code>editor</code> and <code>blog</code> model. Both <code>reader</code> and <code>editor</code> can create a <code>blog</code>.</p>
  
  <p>Here is the original <code>blogs_controller</code>:</p>
  
  <pre><code>    class BlogsController &lt; ApplicationsController        
        def create
          @blog = Blog.new(blog_params)
          respond_to do |format|
            if @blog.save
              format.html { redirect_to @blog }
            else
              format.html { render :new }
            end
          end
        end
  
        private
  
        def blog_params
          params.require(:service).permit(:title, :content)
        end
      end
  </code></pre>