daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Mar 15th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class BookmarksController < ApplicationController
  2.  
  3.     def index
  4.         @title = "Index"
  5.         if params[:tag]
  6.             @bookmarks = Bookmark.tagged_with(params[:tag])
  7.         else
  8.             @bookmarks = Bookmarks.all
  9.         end
  10.     end
  11.  
  12.     def show
  13.         @title = "View Bookmark"
  14.         @bookmark = Bookmark.find(params[:id])
  15.         @bookmark.increment!(:view_count)
  16.     end
  17.  
  18.     def new
  19.         @title = "Create Bookmark"
  20.         @bookmark= Bookmark.new
  21.         @user= User.all
  22.     end
  23.  
  24.     def create
  25.         @bookmark = Bookmark.new(params[:bookmark])
  26.         if @bookmark.save
  27.           redirect_to bookmark_url(@bookmark), :notice => "Created successfully"
  28.         else
  29.           render "new"
  30.         end
  31.     end
  32.  
  33.     def edit
  34.         @title = "Edit Bookmark"
  35.         @bookmark = Bookmark.find(params[:id])
  36.         @user= User.all
  37.     end
  38.  
  39.     def update
  40.         @bookmark = Bookmark.find(params[:id])
  41.  
  42.         if @bookmark.update_attributes(params[:bookmark])
  43.           redirect_to @bookmark, :notice => "Updated!"
  44.  
  45.         else
  46.           render "edit"
  47.         end
  48.     end
  49.  
  50.     def destroy
  51.         @bookmark = Bookmark.find(params[:id])
  52.  
  53.         @bookmark.destroy
  54.  
  55.         redirect_to root_path, :notice => "Deleted"
  56.     end
  57.    
  58.     def popular
  59.         @title = "Popular"
  60.         @bookmarks = Bookmark.all
  61.     end
  62.  
  63. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top