Class: BrilliantCms::EntriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- BrilliantCms::EntriesController
- Defined in:
- app/controllers/brilliant_cms/entries_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #search ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/brilliant_cms/entries_controller.rb', line 33 def create @entry = Entry.new(entry_params) if @entry.save redirect_to content_entry_path(@entry), notice: 'Entry was successfully created.' else render :new end end |
#destroy ⇒ Object
51 52 53 54 |
# File 'app/controllers/brilliant_cms/entries_controller.rb', line 51 def destroy @entry.destroy redirect_to content_entries_path, notice: 'Entry was successfully destroyed.' end |
#edit ⇒ Object
30 31 |
# File 'app/controllers/brilliant_cms/entries_controller.rb', line 30 def edit end |
#index ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/controllers/brilliant_cms/entries_controller.rb', line 7 def index if blog? @entries = blog_posts_with_links.order('id desc') else @entries = Entry.where(type: module_class_string.constantize) end end |
#new ⇒ Object
26 27 28 |
# File 'app/controllers/brilliant_cms/entries_controller.rb', line 26 def new @entry = Entry.new(type: module_class_string) end |
#search ⇒ Object
15 16 17 18 |
# File 'app/controllers/brilliant_cms/entries_controller.rb', line 15 def search @entries = Entry.where(type: module_class_string.constantize).search(params[:query]) render action: 'index' end |
#show ⇒ Object
20 21 22 23 24 |
# File 'app/controllers/brilliant_cms/entries_controller.rb', line 20 def show if blog? @entry = Entry.find_by_slug!(params[:slug]) end end |
#update ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/controllers/brilliant_cms/entries_controller.rb', line 43 def update if @entry.update(entry_params) redirect_to content_entry_path(@entry), notice: 'Entry was successfully updated.' else render :edit end end |