Class: Cms::ConnectorsController

Inherits:
BaseController show all
Defined in:
app/controllers/cms/connectors_controller.rb

Instance Method Summary collapse

Methods included from PageHelper

#able_to?, #cms_content_editor, #cms_toolbar, #container, #container_has_block?, #current_page, #page_title, #render_breadcrumbs, #render_portlet

Methods included from PathHelper

#attachment_path_for, #cms_connectable_path, #cms_index_path_for, #cms_index_url_for, #cms_new_path_for, #cms_new_url_for, #cms_sortable_column_path, #edit_cms_connectable_path, #engine_for, #link_to_usages, #path_elements_for

Methods included from ErrorHandling

#handle_access_denied, #handle_server_error, #with_format

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/cms/connectors_controller.rb', line 14

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

#destroyObject



26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/cms/connectors_controller.rb', line 26

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

#newObject



7
8
9
10
11
12
# File 'app/controllers/cms/connectors_controller.rb', line 7

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