orbit-basic/app/controllers/admin/tags_controller.rb

49 lines
968 B
Ruby
Raw Normal View History

2012-02-14 16:32:20 +00:00
class Admin::TagsController < ApplicationController
layout 'new_admin'
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_module_app
def index
get_tags
@module_app_id = @module_app.id rescue nil
end
def new
end
def edit
@tag = Tag.find(params[:id])
end
def create
2012-02-15 03:42:19 +00:00
@tag = (params[:tag][:module_app_id].blank? ? Tag.create(params[:tag]) : ModuleAppTag.create(params[:tag]))
2012-02-14 16:32:20 +00:00
end
def update
@tag = Tag.find(params[:id])
@tag.update_attributes(params[:tag])
end
def destroy
@tag = Tag.find(params[:id])
@tag.destroy
respond_to do |format|
format.js { render 'js/remove_element', :locals => {:id => "#{dom_id @tag}"} }
end
end
protected
def set_module_app
@module_app ||= ModuleApp.first(:conditions => {:key => @app_title.underscore}) rescue nil
end
def get_tags
@tags = (@module_app ? @module_app.tags : Tag.all)
end
end