RailsCasts Pro episodes are now free!

Learn more or hide this

kevonc's Profile

GitHub User: kevonc

Comments by

Avatar

somehow it now works out of nowhere. i think restarting the server helps!

Avatar

Hi guys, I am very very new to ROR so I really appreciate any help.

When I place the

           has_reputation :votes, source: :user, aggregated_by: :sum

in my post model, my page shows up as

"undefined method `has_reputation' for #Class:0x007fe5708753e0"

and then reloading turns it into

"undefined method `key?' for nil:NilClass"

If I take away these codes in my post model, the page will show fine then I try to click on the "up" button, and this shows up

undefined method `add_evaluation' for #Post:0x007fe57100e2c8

anyone can help me out? thank you so much

this is my post_controller

def vote
value = params[:type] == "up" ? 1 : -1
@post = Post.find(params[:id])
@post.add_or_update_evaluation(:votes, value, current_user)
redirect_to :back, notice: "Thank you for voting"
end