Sha256: 3eb1ee943ed887dce81e7146d17fc06610bba6c807a0d7b0d0e8d9d074752d12
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 KB
Contents
module Elabs module Admin class TagsController < AdminApplicationController DEFAULT_ORDER_FIELD = 'name'.freeze before_action :set_tag, only: %i[edit update destroy] # GET /tags # GET /tags.json def index order = params['order_by'] || self.class::DEFAULT_ORDER_FIELD direction = params['direction'] || 'desc' @tags = Tag.order(order => direction).all end # GET /tags/1/edit def edit; end # PATCH/PUT /tags/1 # PATCH/PUT /tags/1.json def update respond_to do |format| if @tag.update(tag_params) format.html { redirect_to admin_tags_url, notice: _('Tag was successfully updated.') } format.json { render :show, status: :ok, location: admin_tags_url } else format.html { render :edit } format.json { render json: @tag.errors, status: :unprocessable_entity } end end end # DELETE /tags/1 # DELETE /tags/1.json def destroy @tag.destroy respond_to do |format| format.html { redirect_to admin_tags_url, notice: _('Tag was successfully destroyed.') } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_tag @tag = Tag.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def tag_params params.require(:tag).permit(:name) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
elabs-2.0.0 | app/controllers/elabs/admin/tags_controller.rb |
elabs-2.0.0.pre | app/controllers/elabs/admin/tags_controller.rb |