Method: Idioma::PhrasesController#index
- Defined in:
- app/controllers/idioma/phrases_controller.rb
#index ⇒ Object
GET /phrases
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/idioma/phrases_controller.rb', line 8 def index params[:locale_eq] ||= I18n.default_locale scope = Phrase.where(locale: params[:locale_eq]) if params[:q].present? scope = scope.where("i18n_key ilike ? OR i18n_value ilike ?", "%#{params[:q]}%", "%#{params[:q]}%") end respond_to do |format| format.html { @phrases = scope.paginate(:page => params[:page]) } format.csv { render text: PhraseExporter.to_csv(scope) } format.yaml { render text: PhraseExporter.to_yaml(scope) } format.json { @phrases = scope.paginate(:page => params[:page]) render json: { meta: { pagination: { current_page: @phrases.current_page, per_page: @phrases.per_page, total_entries: @phrases.total_entries } }, phrases: @phrases } } end end |