Class: Cortex::ContentItemsController
Instance Method Summary
collapse
#media_asset_field, #media_content_items, #media_content_type, #media_image_content_items, #media_index
#content_item_params, #content_item_reload, #content_type, #create_content_item, #field_item_param_data, #field_items_attributes_params, #index_parameters, #params_lookup, #permit_attribute_params, #permit_param, #sanitize_parameters, #update_content_item, #validation_message
Instance Method Details
#create ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'app/controllers/cortex/content_items_controller.rb', line 57
def create
begin
create_content_item
rescue ActiveRecord::RecordInvalid => e
flash[:warning] = validation_message(e.message)
@content_item = content_item_reload(content_type.content_items.new)
@wizard = wizard_decorator(@content_item.content_type)
add_breadcrumb content_type.name.pluralize, :content_type_content_items_path
add_breadcrumb 'New'
render :new
else
flash[:success] = "Hooray! #{content_type.name} Created!"
redirect_to content_type_content_items_path
end
end
|
#edit ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/cortex/content_items_controller.rb', line 27
def edit
@content_item = content_type.content_items.find_by_tenant(current_user.active_tenant).find_by_id(params[:id])
@wizard = wizard_decorator(@content_item.content_type)
title = @content_item.field_items.find { |field_item| field_item.field.name == 'Title' }.data['text']
add_breadcrumb content_type.name.pluralize, :content_type_content_items_path
add_breadcrumb title
add_breadcrumb 'Edit'
end
|
#index ⇒ Object
9
10
11
12
13
|
# File 'app/controllers/cortex/content_items_controller.rb', line 9
def index
@index = index_decorator(content_type)
@content_items = content_type.content_items.find_by_tenant(current_user.active_tenant)
add_breadcrumb content_type.name.pluralize
end
|
#new ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/cortex/content_items_controller.rb', line 15
def new
@content_item = content_type.content_items.new
content_type.fields.each do |field|
@content_item.field_items << FieldItem.new(field: field)
end
@wizard = wizard_decorator(@content_item.content_type)
add_breadcrumb content_type.name.pluralize, :content_type_content_items_path
add_breadcrumb 'New'
end
|
#update ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'app/controllers/cortex/content_items_controller.rb', line 37
def update
begin
update_content_item
rescue ActiveRecord::RecordInvalid => e
flash[:warning] = validation_message(e.message)
@content_item = content_item_reload(content_type.content_items.find_by_id(params[:id]))
@wizard = wizard_decorator(@content_item.content_type)
title = @content_item.field_items.find { |field_item| field_item.field.name == 'Title' }.data['text']
add_breadcrumb content_type.name.pluralize, :content_type_content_items_path
add_breadcrumb title
add_breadcrumb 'Edit'
render :edit
else
flash[:success] = "Hooray! #{content_type.name} Updated!"
redirect_to content_type_content_items_path
end
end
|