Class: Elabs::Admin::LanguagesController
- Inherits:
-
AdminApplicationController
- Object
- ActionController::Base
- ElabsApplicationController
- AdminApplicationController
- Elabs::Admin::LanguagesController
- Defined in:
- app/controllers/elabs/admin/languages_controller.rb
Constant Summary collapse
- DEFAULT_ORDER_FIELD =
'name'.freeze
Constants inherited from AdminApplicationController
AdminApplicationController::MAX_ITEMS_PER_PAGE
Instance Method Summary collapse
-
#create ⇒ Object
POST /admin/languages POST /admin/languages.json.
-
#destroy ⇒ Object
DELETE /admin/languages/1 DELETE /admin/languages/1.json.
-
#edit ⇒ Object
GET /admin/languages/1/edit.
-
#index ⇒ Object
GET /admin/languages GET /admin/languages.json.
-
#new ⇒ Object
GET /admin/languages/new.
-
#update ⇒ Object
PATCH/PUT /admin/languages/1 PATCH/PUT /admin/languages/1.json.
Instance Method Details
#create ⇒ Object
POST /admin/languages POST /admin/languages.json
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/elabs/admin/languages_controller.rb', line 26 def create @language = Language.new(language_params) respond_to do |format| if @language.save format.html { redirect_to admin_languages_url, notice: _('Language was successfully created.') } format.json { render '_language', status: :created, location: @language, locals: { language: @language } } else format.html { render :new } format.json { render json: @language.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /admin/languages/1 DELETE /admin/languages/1.json
56 57 58 59 60 61 62 |
# File 'app/controllers/elabs/admin/languages_controller.rb', line 56 def destroy @language.destroy respond_to do |format| format.html { redirect_to admin_languages_url, notice: _('Language was successfully destroyed.') } format.json { head :no_content } end end |
#edit ⇒ Object
GET /admin/languages/1/edit
22 |
# File 'app/controllers/elabs/admin/languages_controller.rb', line 22 def edit; end |
#index ⇒ Object
GET /admin/languages GET /admin/languages.json
10 11 12 13 14 |
# File 'app/controllers/elabs/admin/languages_controller.rb', line 10 def index order = params['order_by'] || self.class::DEFAULT_ORDER_FIELD direction = params['direction'] || 'desc' @languages = Language.order(order => direction).page(params[:page]).per(self.class::MAX_ITEMS_PER_PAGE) end |
#new ⇒ Object
GET /admin/languages/new
17 18 19 |
# File 'app/controllers/elabs/admin/languages_controller.rb', line 17 def new @language = Language.new end |
#update ⇒ Object
PATCH/PUT /admin/languages/1 PATCH/PUT /admin/languages/1.json
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/elabs/admin/languages_controller.rb', line 42 def update respond_to do |format| if @language.update(language_params) format.html { redirect_to admin_languages_url, notice: _('Language was successfully updated.') } format.json { render '_language', status: :ok, location: @language, locals: { language: @language } } else format.html { render :edit } format.json { render json: @language.errors, status: :unprocessable_entity } end end end |