Class: LinkController

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

Constant Summary

Constants included from PaginationHelper

PaginationHelper::DEFAULT_OPTIONS, PaginationHelper::OPTIONS

Instance Method Summary collapse

Methods included from PaginationHelper

included, #paginate, validate_options!

Instance Method Details

#destroyObject



25
26
27
28
# File 'app/controllers/link_controller.rb', line 25

def destroy
  current_user.links.find(@params['id']).destroy rescue nil
  redirect_to_link
end

#indexObject



4
5
6
7
# File 'app/controllers/link_controller.rb', line 4

def index
  list
  render_action 'list'
end

#listObject



9
10
11
# File 'app/controllers/link_controller.rb', line 9

def list
  @links = current_user.links || []
end

#newObject



13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/link_controller.rb', line 13

def new
  @link = current_user.links.build
  if @request.post?
    @link.attributes = @params['link']
    if @link.save
      flash['notice'] = "Link was successfully saved."
      redirect_to_link
      return
    end
  end
end