Class: WritersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- WritersController
- Defined in:
- app/controllers/writers_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
caches_page_with_cache_marker, #raise_not_found!
Instance Method Details
#check ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/controllers/writers_controller.rb', line 10 def check @writer = TranslationCms::Api::Writer.new(id: params[:id]).exists respond_to do |format| format.json { render json: { id: @writer.blank? ? nil : @writer.first.try(:id) } } format.all { raise ActiveRecord::RecordNotFound, "Writer #{params[:id]} not found" } end end |
#index ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/writers_controller.rb', line 18 def index @no_writers_text = structure_by(slug: 'additional-no-writers-found-text').try(:main) @languages = TranslationCms::Api::Language.all! @industries = TranslationCms::Api::IndustryExpertise.all! @statuses = WriterActivityState.filter_list @filter_state = WriterActivityState.find_by(slug: params[:activity_state]) @sort_column = WriterSortType.find_by(slug: params[:sort_column]) @sort_order = SortOrder.find_by(slug: params[:sort_order]) @writers = TranslationCms::Api::Writer.page(params[:page]).per(params[:per]).where(permited_params).all @page_offset = params[:per].to_i * (@writers.current_page - 1) respond_with @writers end |
#show ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/writers_controller.rb', line 34 def show params[:per] = 10 if params[:per].blank? || params[:per].to_i < 1 api_responce = TranslationCms::Api::Writer.find(params[:id]) raise ActiveRecord::RecordNotFound, "Writer #{params[:id]} not found" if api_responce.errors.present? @writer = api_responce.first @feedbacks = @writer.writer_feedbacks @industries = TranslationCms::Api::IndustryExpertise.all! # Seo meta tags @meta_record = @writer respond_with @writer end |