简体   繁体   中英

how to install 'impressionist' plugin manually step by step? (ruby on rails)

This would really help out a lot. I tried to install the plugin through the command and I can't ever seem to get it working correctly. ( https://github.com/charlotte-ruby/impressionist ) Can someone outline the steps numerically with the specific line of codes that would be used and the file names? #1-10, etc? I'm trying to track the number of times people click into a user's profile (ie localhost:3000/users/1). The # of times a profile is viewed in other words so that I can show it on localhost:3000/users view but that will be the next step.

This is what I have done so far: 1. bundle installed gem 'impressionist'

  1. tried to run "rails g impressionist" and "rake db:migrate" but I'm trying to figure out if it worked or not

  2. created a controller file named "widgets_controller.rb inside app\\controllers\\ which has the following code

    WidgetsController < ApplicationController impressionist :actions=>[:show,:index]

    end

  3. create a model file named widget.rb inside app\\models which has the following code

    class Widget < ActiveRecord::Base is_impressionable end

  4. added this line inside the app\\models\\user.rb file

    def show @widget = Widget.find impressionist(@widget,message:"wtf is a widget?") #message is optional end

  5. Then I'm using this code line @widget.impressionist_count in my views to try to display the count.

You just have to follow the tutorial at impressionist page.

1 - Add line gem 'impressionist' to your gemfile and run bundle install command, than run rails g impressionist and rake db:migrate commands. 2 - In the controller you want to track (in your case users_controller) add

class UsersController < ApplicationController

impressionist :actions => [:show]

3 - In the model user.rb add

class User < ActiveRecord::Base

is_impressionable

4 - In users/index.html.erb view add

<%= @user.impressionist_count %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM