Sha256: 27c960f4028d7cf001567ec9bdfce3950f7f543109cf266bd559c43c0f21c382

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

class SearchHistoriesController < ApplicationController
  # index, show以外は外部からは呼び出されないはず
  load_and_authorize_resource

  # GET /search_histories
  # GET /search_histories.json
  def index
    if params[:mode] == 'not_found'
      if current_user.has_role?('Administrator')
        @search_histories = SearchHistory.not_found.order('created_at DESC').page(params[:page])
      else
        @search_histories = current_user.search_histories.not_found.order('created_at DESC').page(params[:page])
      end
    else
      if current_user.has_role?('Administrator')
        @search_histories = SearchHistory.order('created_at DESC').page(params[:page])
      else
        @search_histories = current_user.search_histories.order('created_at DESC').page(params[:page])
      end
    end

    respond_to do |format|
      format.html # index.html.erb
      format.json { render :json => @search_histories.to_json }
    end
  end

  # GET /search_histories/1
  # GET /search_histories/1.json
  def show
    respond_to do |format|
      format.html # show.html.erb
      format.json { render :json => @search_history.to_json }
    end
  end

  # DELETE /search_histories/1
  # DELETE /search_histories/1.json
  def destroy
    @search_history.destroy

    respond_to do |format|
      format.html { redirect_to search_histories_url }
      format.json { head :no_content }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
enju_search_log-0.0.6 app/controllers/search_histories_controller.rb
enju_search_log-0.0.5 app/controllers/search_histories_controller.rb
enju_search_log-0.0.4 app/controllers/search_histories_controller.rb