Class: BrilliantCms::EntriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/brilliant_cms/entries_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

#destroyObject



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

#editObject



30
31
# File 'app/controllers/brilliant_cms/entries_controller.rb', line 30

def edit
end

#indexObject



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

#newObject



26
27
28
# File 'app/controllers/brilliant_cms/entries_controller.rb', line 26

def new
  @entry = Entry.new(type: module_class_string)
end

#searchObject



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

#showObject



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

#updateObject



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