Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BookmarksController < ApplicationController
- def index
- @title = "Index"
- if params[:tag]
- @bookmarks = Bookmark.tagged_with(params[:tag])
- else
- @bookmarks = Bookmarks.all
- end
- end
- def show
- @title = "View Bookmark"
- @bookmark = Bookmark.find(params[:id])
- @bookmark.increment!(:view_count)
- end
- def new
- @title = "Create Bookmark"
- @bookmark= Bookmark.new
- @user= User.all
- end
- def create
- @bookmark = Bookmark.new(params[:bookmark])
- if @bookmark.save
- redirect_to bookmark_url(@bookmark), :notice => "Created successfully"
- else
- render "new"
- end
- end
- def edit
- @title = "Edit Bookmark"
- @bookmark = Bookmark.find(params[:id])
- @user= User.all
- end
- def update
- @bookmark = Bookmark.find(params[:id])
- if @bookmark.update_attributes(params[:bookmark])
- redirect_to @bookmark, :notice => "Updated!"
- else
- render "edit"
- end
- end
- def destroy
- @bookmark = Bookmark.find(params[:id])
- @bookmark.destroy
- redirect_to root_path, :notice => "Deleted"
- end
- def popular
- @title = "Popular"
- @bookmarks = Bookmark.all
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement