Class: BookmarksController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#api_request?, #welcome

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#createObject


26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/bookmarks_controller.rb', line 26

def create
  @bookmark = Bookmark.new(params[:bookmark])

  respond_to do |format|
    if @bookmark.save
      format.html { redirect_to send("#{@bookmark.controller}_path"), :notice => _('Bookmark was successfully created.') }
    else
      format.html { render :action => "new" }
    end
  end
end

#destroyObject


48
49
50
51
52
53
54
# File 'app/controllers/bookmarks_controller.rb', line 48

def destroy
  @bookmark.destroy

  respond_to do |format|
    format.html { redirect_to(bookmarks_url) }
  end
end

#editObject


23
24
# File 'app/controllers/bookmarks_controller.rb', line 23

def edit
end

#indexObject


4
5
6
7
8
9
10
11
# File 'app/controllers/bookmarks_controller.rb', line 4

def index
  @bookmarks = Bookmark.paginate(:page => params[:page])

  respond_to do |format|
    format.html
    format.json { render :json => @bookmarks }
  end
end

#newObject


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

def new
  @bookmark            = Bookmark.new
  @bookmark.name       = params[:query].to_s.strip.split(/\s| = |!|~|>|</)[0]
  @bookmark.controller = params[:kontroller]

  respond_to do |format|
    format.html
  end
end

#updateObject


38
39
40
41
42
43
44
45
46
# File 'app/controllers/bookmarks_controller.rb', line 38

def update
  respond_to do |format|
    if @bookmark.update_attributes(params[:bookmark])
      format.html { redirect_to(bookmarks_path, :notice => _('Bookmark was successfully updated.')) }
    else
      format.html { render :action => "edit" }
    end
  end
end