Class: LocSearchController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- LocSearchController
- Defined in:
- app/controllers/loc_search_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/loc_search_controller.rb', line 21 def create begin @manifestation = LocSearch.import_from_sru_response(params[:book].try(:[], 'lccn')) rescue EnjuLoc::RecordNotFound end respond_to do |format| if @manifestation.try(:save) flash[:notice] = t('controller.successfully_created', model: t('activerecord.models.manifestation')) format.html { redirect_to manifestation_url(@manifestation) } else if @manifestation and not @manifestation.valid? flash[:notice] = @manifestation.errors. else flash[:notice] = t('enju_loc.record_not_found') end format.html { redirect_to loc_search_index_url } end end end |
#index ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/loc_search_controller.rb', line 4 def index if params[:page].to_i <= 0 page = 1 else page = params[:page].to_i end @query = params[ :query ].to_s.strip books = LocSearch.search( @query, { page: page } ) @books = Kaminari.paginate_array( books[:items], total_count: books[ :total_entries ] ).page( page ).per( 10 ) respond_to do |format| format.html end end |