dcalixto
dcalixto

Reputation: 411

Reputation-system get upvoted items

I'm trying to iterate over a post model and show to the user just the upvoted posted. the way that seems on docs is this:

def vote
    value = params[:type] == "Vote" ? 1 : 0
 @post = Post.find(params[:id])
 @post.add_or_update_evaluation(:votes, value, current_user)
 redirect_to :back
  end


def index
    @posts = Post.where(current_user.id).find_with_reputation(:votes, value: 1.0).paginate(page: params[:page], per_page: 22)

end

<ul>
<% @posts.each do |post| %>
<li><span><%= link_to post.author.name,  author_path(author.id)%></span></li>
<li><span><%=  link_to post.title post_path(post.id) %></span></li>
<li><p><%= post.body %></p></li>
<li><%= post.created_at %></li>
  </ul>

but rails is spitting out Unknown key: value. someone have any tip for this? thank's

Upvotes: 0

Views: 46

Answers (1)

Rodrigo Martinez
Rodrigo Martinez

Reputation: 711

2nd parameter in find_with_reputation is scope so you probably mean either: find_with_reputation(:votes, :all, {:conditions => ["votes = ?", value]}) or find_with_reputation(:votes, :all, {:conditions => ["votes = ?", 1.0]})

Upvotes: 1

Related Questions