Class: Admin::Odania::ContentsController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::Odania::ContentsController
- Defined in:
- app/controllers/admin/odania/contents_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /admin/contents.
-
#destroy ⇒ Object
DELETE /admin/contents/1.
-
#edit ⇒ Object
GET /admin/contents/1/edit.
-
#index ⇒ Object
GET /admin/contents.
-
#new ⇒ Object
GET /admin/contents/new.
- #overview ⇒ Object
-
#show ⇒ Object
GET /admin/contents/1.
-
#update ⇒ Object
PATCH/PUT /admin/contents/1.
Instance Method Details
#create ⇒ Object
POST /admin/contents
29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/admin/odania/contents_controller.rb', line 29 def create @admin_content = Odania::Content.new(admin_content_params) @admin_content.user_id = current_user.id if @admin_content.save redirect_to , notice: 'Content was successfully created.' else render action: 'new' end end |
#destroy ⇒ Object
DELETE /admin/contents/1
50 51 52 53 |
# File 'app/controllers/admin/odania/contents_controller.rb', line 50 def destroy @admin_content.destroy redirect_to , notice: 'Content was successfully destroyed.' end |
#edit ⇒ Object
GET /admin/contents/1/edit
25 26 |
# File 'app/controllers/admin/odania/contents_controller.rb', line 25 def edit end |
#index ⇒ Object
GET /admin/contents
5 6 7 8 9 10 11 |
# File 'app/controllers/admin/odania/contents_controller.rb', line 5 def index if @odania_menu.nil? @admin_contents = @admin_site.contents.order('title ASC') else @admin_contents = @admin_site.contents.where(language_id: @odania_menu.language.id).order('title ASC') end end |
#new ⇒ Object
GET /admin/contents/new
18 19 20 21 22 |
# File 'app/controllers/admin/odania/contents_controller.rb', line 18 def new @admin_content = Odania::Content.new @admin_content.site_id = @admin_site.id @admin_content.language_id = @odania_menu.language.id unless @odania_menu.nil? end |
#overview ⇒ Object
55 56 57 58 59 60 |
# File 'app/controllers/admin/odania/contents_controller.rb', line 55 def overview = Odania::Menu.first redirect_to , notice: 'Create a menu first' if .nil? redirect_to (menu_id: .id.to_s) end |
#show ⇒ Object
GET /admin/contents/1
14 15 |
# File 'app/controllers/admin/odania/contents_controller.rb', line 14 def show end |
#update ⇒ Object
PATCH/PUT /admin/contents/1
41 42 43 44 45 46 47 |
# File 'app/controllers/admin/odania/contents_controller.rb', line 41 def update if @admin_content.update(admin_content_params) redirect_to , notice: 'Content was successfully updated.' else render action: 'edit' end end |