Class: Caseadilla::RolesController

Inherits:
CaseadillaController show all
Defined in:
app/controllers/caseadilla/roles_controller.rb

Instance Method Summary collapse

Methods inherited from CaseadillaController

#blank

Methods included from ConfigHelper

#caseadilla_config_dashboard_url, #caseadilla_config_email_from_address, #caseadilla_config_hostname, #caseadilla_config_javascript_includes, #caseadilla_config_logo, #caseadilla_config_stylesheet_includes, #caseadilla_config_website_name

Methods included from CaseadillaHelper

#caseadilla_check_box, #caseadilla_check_box_group, #caseadilla_collection_check_boxes, #caseadilla_collection_select, #caseadilla_color_field, #caseadilla_custom_field, #caseadilla_date_field, #caseadilla_date_select, #caseadilla_datetime_field, #caseadilla_datetime_local_field, #caseadilla_datetime_select, #caseadilla_email_field, #caseadilla_file_field, #caseadilla_format_date, #caseadilla_format_datetime, #caseadilla_format_time, #caseadilla_generate_page_title, #caseadilla_get_access_level_array, #caseadilla_get_access_level_text, #caseadilla_get_footer_string, #caseadilla_get_full_version_string, #caseadilla_get_short_version_string, #caseadilla_hidden_field, #caseadilla_month_field, #caseadilla_no_yes_label, #caseadilla_number_field, #caseadilla_pagination_details, #caseadilla_password_field, #caseadilla_radio_button, #caseadilla_radio_button_group, #caseadilla_range_field, #caseadilla_search_field, #caseadilla_select, #caseadilla_show_icon, #caseadilla_show_row_icon, #caseadilla_sort_link, #caseadilla_table_cell_link, #caseadilla_table_cell_no_link, #caseadilla_telephone_field, #caseadilla_text_area, #caseadilla_text_area_wysiwym, #caseadilla_text_field, #caseadilla_time_field, #caseadilla_time_select, #caseadilla_time_zone_select, #caseadilla_url_field, #caseadilla_week_field, #caseadilla_yes_no_label

Instance Method Details

#createObject


24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/caseadilla/roles_controller.rb', line 24

def create
  @role = Role.new role_params

  if @role.save
    flash[:notice] = 'Role created'
    redirect_to caseadilla_roles_path
  else
    flash.now[:warning] = 'There were problems when trying to create a new role'
    render :action => :new
  end
end

#destroyObject


50
51
52
53
54
55
56
# File 'app/controllers/caseadilla/roles_controller.rb', line 50

def destroy
  @role = Role.find params[:id]

  @role.destroy
  flash[:notice] = 'Role has been deleted'
  redirect_to caseadilla_roles_path
end

#indexObject

optional filters for defining usage according to Caseadilla::AdminUser access_levels before_filter :needs_admin, :except => [:action1, :action2] before_filter :needs_admin_or_current_user, :only => [:action1, :action2]


9
10
11
12
# File 'app/controllers/caseadilla/roles_controller.rb', line 9

def index
  @caseadilla_page_title = 'Roles'
@roles = Role.order(sort_order(:title)).paginate :page => params[:page]
end

#newObject


19
20
21
22
# File 'app/controllers/caseadilla/roles_controller.rb', line 19

def new
  @caseadilla_page_title = 'Add a new role'
	@role = Role.new
end

#showObject


14
15
16
17
# File 'app/controllers/caseadilla/roles_controller.rb', line 14

def show
  @caseadilla_page_title = 'View role'
  @role = Role.find params[:id]
end

#updateObject


36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/caseadilla/roles_controller.rb', line 36

def update
  @caseadilla_page_title = 'Update role'
  
  @role = Role.find params[:id]

  if @role.update_attributes role_params
    flash[:notice] = 'Role has been updated'
    redirect_to caseadilla_roles_path
  else
    flash.now[:warning] = 'There were problems when trying to update this role'
    render :action => :show
  end
end