Class | Cms::ConnectorsController |
In: |
app/controllers/cms/connectors_controller.rb
|
Parent: | Cms::BaseController |
# File app/controllers/cms/connectors_controller.rb, line 13 13: def create 14: @block_type = ContentType.find_by_key(params[:connectable_type]) 15: raise "Unknown block type" unless @block_type 16: @block = @block_type.model_class.find(params[:connectable_id]) 17: if @page.create_connector(@block, params[:container]) 18: redirect_to @page.path 19: else 20: @blocks = @block_type.model_class.all(:order => "name") 21: render :action => 'new' 22: end 23: end
# File app/controllers/cms/connectors_controller.rb, line 25 25: def destroy 26: @connector = Connector.find(params[:id]) 27: @page = @connector.page 28: @connectable = @connector.connectable 29: if @page.remove_connector(@connector) 30: flash[:notice] = "Removed '#{@connectable.name}' from the '#{@connector.container}' container" 31: else 32: flash[:error] = "Failed to remove '#{@connectable.name}' from the '#{@connector.container}' container" 33: end 34: redirect_to @page.path 35: end
# File app/controllers/cms/connectors_controller.rb, line 6 6: def new 7: @block_type = ContentType.find_by_key(params[:block_type] || session[:last_block_type] || 'html_block') 8: @container = params[:container] 9: @connector = @page.connectors.build(:container => @container) 10: @blocks = @block_type.model_class.all(:order => "name", :conditions => ["deleted = ?", false]) 11: end