Class: Cms::ConnectorsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationController
- ApplicationController
- BaseController
- Cms::ConnectorsController
- Defined in:
- app/controllers/cms/connectors_controller.rb
Instance Method Summary collapse
Methods included from PageHelper
#able_to?, #cms_toolbar, #container, #container_has_block?, #current_page, #page_title, #render_breadcrumbs, #render_portlet
Methods included from PathHelper
#cms_connectable_path, #cms_index_path_for, #cms_index_url_for, #cms_new_path_for, #cms_new_url_for, #edit_cms_connectable_path
Methods included from ErrorHandling
#handle_access_denied, #handle_server_error, included
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/cms/connectors_controller.rb', line 13 def create @block_type = ContentType.find_by_key(params[:connectable_type]) raise "Unknown block type" unless @block_type @block = @block_type.model_class.find(params[:connectable_id]) if @page.create_connector(@block, params[:container]) redirect_to @page.path else @blocks = @block_type.model_class.all(:order => "name") render :action => 'new' end end |
#destroy ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/cms/connectors_controller.rb', line 25 def destroy @connector = Connector.find(params[:id]) @page = @connector.page @connectable = @connector.connectable if @page.remove_connector(@connector) flash[:notice] = "Removed '#{@connectable.name}' from the '#{@connector.container}' container" else flash[:error] = "Failed to remove '#{@connectable.name}' from the '#{@connector.container}' container" end redirect_to @page.path end |
#new ⇒ Object
6 7 8 9 10 11 |
# File 'app/controllers/cms/connectors_controller.rb', line 6 def new @block_type = ContentType.find_by_key(params[:block_type] || session[:last_block_type] || 'html_block') @container = params[:container] @connector = @page.connectors.build(:container => @container) @blocks = @block_type.model_class.all(:order => "name", :conditions => ["deleted = ?", false]) end |