title: Rails url paths and resource routing
body: <p>I have a specific question. So I'll understand if nobody helps me. :) Anyway, thanks in advance! How can I refactor this code using resources and restful agreement? Especially I mean <code>render_with_hashtags_of_question(text)</code> and <code>render_with_hashtags_of_answer(text)</code> methods and relevant route 
  <code>get '/questions/hashtag/:name', to: 'questions#hashtags'</code></p>
  
  <p>Question model:</p>
  
  <pre><code>require 'active_support/all'
  
  class Question &lt; ActiveRecord::Base
    TAG_REGEX = (/#[\p{L}_]+/)
  
    belongs_to :user
    belongs_to :author, class_name: 'User'
    has_and_belongs_to_many :tags
  
    validates :text, :user, presence: true
    validates :text, length: { maximum: 255 }
  
    after_save :add_hashtags
  
    after_commit do
      self.tags.clear
      add_hashtags
    end
  
    private
  
    def add_hashtags
      hashtags = self.text.scan(TAG_REGEX)
      hashtags &lt;&lt; self.answer.scan(TAG_REGEX) if self.answer.present?
      hashtags.uniq.map do |hashtag|
        tag = Tag.find_or_create_by(name: hashtag.to_s.mb_chars.downcase.delete('#[]"'))
        self.tags &lt;&lt; tag
      end
    end
  end
  </code></pre>
  
  <p>question_controller.rb:</p>
  
  <pre><code>class QuestionsController &lt; ApplicationController
    before_action :load_question, only: [:show, :edit, :update, :destroy]
    before_action -&gt; { authorize_owner(@question.user) }, only: [:update, :destroy]
  
    def index; end
  
    def show; end
  
    def edit; end
  
    def hashtags
      tag = Tag.find_by(name: params[:name])
      @questions = tag.questions
    end
  
    def create
      @question = Question.new(question_params)
      @question.author = current_user if current_user.present?
  
      if check_captcha(@question) &amp;&amp; @question.save
        redirect_to user_path(@question.user), notice: 'Question was successfully created.'
      else
        render :edit
      end
    end
  
    def update
      if check_captcha(@question) &amp;&amp; @question.update(question_params)
        redirect_to user_path(@question.user), notice: 'Question was successfully edited.'
      else
        render :edit
      end
    end
  
    def destroy
      user = @question.user
      @question.destroy
      redirect_to user_path(user), notice: 'Question was successfully deleted.'
    end
  
    private
  
    def load_question
      @question = Question.find(params[:id])
    end
  
    def authorize_owner(user)
      reject_user unless user == current_user
    end
  
    def question_params
      if current_user.present? &amp;&amp; params[:question][:user_id].to_i == current_user.id
        params.require(:question).permit(:user_id, :text, :answer, :tag_id, :tag, { tag_ids: [] }, :tag_ids)
      else
        params.require(:question).permit(:user_id, :text, :tag_id, :tag, { tag_ids: [] }, :tag_ids)
      end
    end
  
    def check_captcha(model)
      verify_recaptcha(model: model) unless current_user.present?
    end
  end
  </code></pre>
  
  <p>question_helper.rb:</p>
  
  <pre><code>require 'active_support/all'
  
  module QuestionsHelper
    TAG_REGEX = (/#[\p{L}_]+/)
  
    def render_with_hashtags_of_question(text)
      text.gsub(TAG_REGEX){
        |word| link_to word, "/questions/hashtag/#{word.mb_chars.downcase.delete('#')}"
      }.html_safe
    end
  
    def render_with_hashtags_of_answer(answer)
      answer&amp;.gsub(TAG_REGEX){
       |word| link_to word, "/questions/hashtag/#{word.mb_chars.downcase.delete('#')}"
      }&amp;.html_safe
    end
  end
  </code></pre>
  
  <p>routes.rb:</p>
  
  <pre><code>Rails.application.routes.draw do
    root 'users#index'
  
    resources :users
    resource :session, only: [:new, :create, :destroy]
    resources :questions, except: [:new] , :index]
  
    get '/questions/hashtag/:name', to: 'questions#hashtags'
  end
  </code></pre>
  
  <p>schema.rb:</p>
  
  <pre><code>ActiveRecord::Schema.define(version: 20161227111328) do
  
    create_table "questions", force: :cascade do |t|
      t.string   "text"
      t.string   "answer"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
      t.integer  "user_id"
      t.integer  "author_id"
    end
  
    add_index "questions", ["user_id"], name: "index_questions_on_user_id"
  
    create_table "questions_tags", id: false, force: :cascade do |t|
      t.integer "question_id"
      t.integer "tag_id"
    end
  
    add_index "questions_tags", ["question_id"], name: "index_questions_tags_on_question_id"
    add_index "questions_tags", ["tag_id"], name: "index_questions_tags_on_tag_id"
  
    create_table "tags", force: :cascade do |t|
      t.string   "name"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
    end
  
    create_table "users", force: :cascade do |t|
      t.string   "name"
      t.string   "username"
      t.datetime "created_at",       null: false
      t.datetime "updated_at",       null: false
      t.string   "email"
      t.string   "password_hash"
      t.string   "password_salt"
      t.string   "avatar_url"
      t.text     "background_color"
      t.text     "font_color"
    end
  
  end
  </code></pre>
  
  <p>I've tried hard to solve the problem for several days honestly, but eventually have got nothing.</p>