Sha256: b388287ec8eafb7f2c7c222cc2371eff4a85f1deb4e214fd3b9e1bf5627e5e67
Contents?: true
Size: 1.45 KB
Versions: 38
Compression:
Stored size: 1.45 KB
Contents
module Pulitzer class TagsController < ApplicationController before_filter :get_tag, only: [:edit, :update, :destroy] rescue_from ActiveRecord::RecordNotFound, with: :render_not_found def index @root_tags = Tag.root @flat_tags = Tag.flat render partial: 'index' end def new @tag = Tag.new(tag_params) render partial: new_template(@tag) end def edit render partial: 'form', locals: { tag: @tag } end def show @tag = Tag.find(params[:id]) render partial: 'show', locals: { tag: @tag } end def create @tag = Tag.new(tag_params) if @tag.save render partial: 'show_wrapper', locals: { tag: @tag } else render partial: new_template(@tag), locals: { tag: @tag }, status: 409 end end def update if @tag.update_attributes(tag_params) render partial: 'show', locals: { tag: @tag } else render partial: 'form', locals: { tag: @tag }, status: 409 end end def destroy @tag.destroy render nothing: true end protected def new_template(tag) tag.hierarchical? ? 'new_hierarchical' : 'new_flat' end def render_not_found(e) Rails.logger.warn("Rendering 404 because #{e.inspect}") render nothing: true, status: :not_found end def tag_params params[:tag].permit! end def get_tag @tag = Tag.find(params[:id]) end end end
Version data entries
38 entries across 38 versions & 1 rubygems