ruby on rails - Acts As Votable With Public Activity -


i'm working on app people can posts. i'm using public activity gem , acts votable.

i'm getting error when try view page:

undefined method 'get_upvotes' publicactivity::activity:0x00000101453ad8 

get_upvotes supposed come acts_as_votable. doing wrong?

user model

class user < activerecord::base     acts_as_voter end 

activity model

class activity < activerecord::base     acts_as_votable end 

view code

<% if activity.owner == current_user %>     <i>this has been liked <strong><%= activity.get_upvotes.size %></strong> times</i> <% else %>     <%= link_to like_activity_path(activity),  class: "like", method: :put %>       <button type="button" class="btn btn-info" aria-label="left align">         <span class="glyphicon glyphicon-thumbs-up glyphicon-align-center" aria-hidden="true"></span>         <span class="badge"><%= activity.get_upvotes.size %></span>       </button>     <% end %>      <a class="btn btn-default btn-xs timeline-button"><i class="fa fa-heart"></i> liked this</a> <% end %> 

activities controller

class activitiescontroller < applicationcontroller      before_action :authenticate_user!, only: [:index, :upvote]      def index         @users = current_user.active_friends         @users.push(current_user)         case params[:content] when 'posts'             @activities = publicactivity::activity.where(owner_id: @users, trackable_type: "post").paginate(page: params[:page], per_page: 6).order('created_at desc')         else             @activities = publicactivity::activity.where(owner_id: @users).paginate(page: params[:page], per_page: 6).order('created_at desc')         end     end      def upvote         @activity = activity.find(params[:id])         @activity.upvote_from current_user         redirect_to activities_path     end  end 

thanks can offer. i'm @ edge of rails knowledge. :)

the activity model lives inside publicactivity module, meaning should work.

class publicactivity::activity   acts_as_votable end 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -