Question

I've added acts_as_votable to my project and I've gotten voting to work. Now I'm trying to filter my models. For example, I have a media model that members can vote on and I want to create a section where they can see all of the media they've up voted on but I get this error:

undefined method `joins' for #<Medium:0x8286810>

I'm not sure what this means nor how to fix it. Any help would be greatly appreciated.

profiles_controller:

def media
    @medium = current_member.medium.new
    @member = Member.find_by_user_name(params[:id])
    if @member 
      @media = @member.get_up_voted(@medium) 
      render action: :media
    else
      render file: 'public/404', status: 404, formats: [:html]
    end
  end

media_controller:

  def upvote
    @medium = Medium.find(params[:id])
    if current_member.voted_up_on? @medium
      @medium.unliked_by current_member
    else 
      @medium.liked_by current_member
    end
    respond_to do |format|
        format.html { redirect_to :back }
        format.js
    end
  end
Was it helpful?

Solution

This was a simple mistake on my part the controller code needed to be:

@media = @member.get_up_voted Medium
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top