Class: CamaleonCms::Admin::Appearances::Widgets::AssignController

Inherits:
CamaleonCms::AdminController
  • Object
show all
Defined in:
app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb

Overview

Camaleon CMS is a content management system

Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
This program is free software: you can redistribute it and/or modify   it under the terms of the GNU Affero General Public License as  published by the Free Software Foundation, either version 3 of the  License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the  GNU Affero General Public License (GPLv3) for more details.

Instance Method Summary collapse

Instance Method Details

#destroyObject



30
31
32
33
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb', line 30

def destroy
  @assigned.destroy
  render inline: ''
end

#newObject



14
15
16
17
18
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb', line 14

def new
  @widget = current_site.widgets.find(params[:widget_id])
  @assigned = @sidebar.assigned.create!({title: "Default", widget_id: @widget.id})
  render partial: "form", locals: {assigned: @assigned, widget: @widget, sidebar: @sidebar}, layout: "camaleon_cms/admin/ajax"
end

#updateObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb', line 20

def update
  if @assigned.update(params[:assign])
    @assigned.set_field_values(params[:field_options])
    flash[:notice] = t('camaleon_cms.admin.widgets.assign.updated')
  else
    flash[:error] = t('camaleon_cms.admin.widgets.assign.error_updated')
  end
  redirect_to cama_admin_appearances_widgets_main_index_path
end