social-media-like

Limit user to 1 like?

*爱你&永不变心* 提交于 2020-01-25 11:19:52
问题 How can we limit a user to 1 like per comment? comments_controller.rb def like @comment = Comment.find(params[:id]) @comment.increment!(:likes) @comment.create_activity :like flash[:success] = 'Thanks for liking!' redirect_to(:back) end _comments.html.erb <% @comments.each do |comment| %> <%= User.find(comment.user_id).name %> <%= simple_format comment.content %> <%= pluralize(comment.likes, 'like') %> <%= link_to content_tag(:span, '', class: 'glyphicon glyphicon-thumbs-up') + ' Like it',

Limit user to 1 like?

送分小仙女□ 提交于 2020-01-25 11:19:11
问题 How can we limit a user to 1 like per comment? comments_controller.rb def like @comment = Comment.find(params[:id]) @comment.increment!(:likes) @comment.create_activity :like flash[:success] = 'Thanks for liking!' redirect_to(:back) end _comments.html.erb <% @comments.each do |comment| %> <%= User.find(comment.user_id).name %> <%= simple_format comment.content %> <%= pluralize(comment.likes, 'like') %> <%= link_to content_tag(:span, '', class: 'glyphicon glyphicon-thumbs-up') + ' Like it',

Tumblr like button not working after infinite scroll ajax recall

≯℡__Kan透↙ 提交于 2019-12-30 05:26:08
问题 There are a few similar posts but they are quite out of date and Tumblr has updated the like part of the API not too long ago as far as I'm aware. Creating a like button is as simple as {LikeButton} and this works great, but after the ajax recalls to get more posts from what would be the next page, the like button no longer works. I have had a look at the documentation and it states that I need to implement one of the following, I was wondering if anyone could point me in the right direction?

Public votes and avoiding mutliple vote: using cookies or IP?

倾然丶 夕夏残阳落幕 提交于 2019-12-21 20:29:55
问题 How do you handle public vote (anyone can "like or dislike" an article) and to restrict him to vote only one time? Have I to use cookies? (with the problem that he can remove the cookie and vote x999 times) or I store his IP in database? 回答1: The solution has three parts: use a cookie to prevent double votes store all vote events in the database (ip, user agent, poll/article id, vote) implement an algorithm which will run every 24h to delete the double votes which escaped from #1. The algo

Public votes and avoiding mutliple vote: using cookies or IP?

自古美人都是妖i 提交于 2019-12-21 20:29:04
问题 How do you handle public vote (anyone can "like or dislike" an article) and to restrict him to vote only one time? Have I to use cookies? (with the problem that he can remove the cookie and vote x999 times) or I store his IP in database? 回答1: The solution has three parts: use a cookie to prevent double votes store all vote events in the database (ip, user agent, poll/article id, vote) implement an algorithm which will run every 24h to delete the double votes which escaped from #1. The algo

acts_as_votable thumbs up/down buttons

孤街浪徒 提交于 2019-12-17 17:59:42
问题 I installed the acts_as_votable gem, it works in the console like it should (like it says in the documentation). So my question is how to set up a form for upvote and downvote buttons? or can they simply be links? here is the documentation: github.com/ryanto/acts_as_votable/blob/master/README.markdown I have a user and a picture model; the user is supposed to be able to like the picture. code from the picture view, where the buttons should be: <% for picture in @pictures %> <p> <%= image_tag

Instagram auto like Bookmarklet

a 夏天 提交于 2019-12-10 11:19:52
问题 Instagram Like (heart) auto click Post Bookmarklet Objective: Click all "Like" heart on page http://www.gramfeed.com/instagram/tags#photo Here is the code I was working with. This one worked on another site, var a = document.getElementsByTagName('a'); var b = []; for(var i=0, len = a.length; i < len; i++){ if(a[i].id.indexOf('like') !== -1){b.push(a[i]) } }; for(var i=0, len = b.length; i < len; i++){ b[i].click() }; 回答1: The following should work; I've tested it on my end, and it likes the

Instagram auto like Bookmarklet

风格不统一 提交于 2019-12-06 09:27:11
Instagram Like (heart) auto click Post Bookmarklet Objective: Click all "Like" heart on page http://www.gramfeed.com/instagram/tags#photo Here is the code I was working with. This one worked on another site, var a = document.getElementsByTagName('a'); var b = []; for(var i=0, len = a.length; i < len; i++){ if(a[i].id.indexOf('like') !== -1){b.push(a[i]) } }; for(var i=0, len = b.length; i < len; i++){ b[i].click() }; Daedalus - Reinstate Monica The following should work; I've tested it on my end, and it likes the hearts(though that doesn't work since I'm not logged in, etc). javascript:

Rails Acts_as_votable Gem Like/Unlike Buttons with Ajax

戏子无情 提交于 2019-12-06 05:31:14
问题 I'm new to Ruby On Rails, I used the acts_as_votable gem to create Like and Unlike Buttons to make Users like and unlike Posts but I can't make them change from Like to Unlike (and viceversa) and update the counter each time they click without refreshing the page. I tried following other kind-of-similar answers but I had no luck. Without the messy changes I tried to do to implement Ajax my code looked like this: Post Model acts_as_votable and User Model acts_as voter Posts Controller has def

Public votes and avoiding mutliple vote: using cookies or IP?

邮差的信 提交于 2019-12-04 13:42:41
How do you handle public vote (anyone can "like or dislike" an article) and to restrict him to vote only one time? Have I to use cookies? (with the problem that he can remove the cookie and vote x999 times) or I store his IP in database? The solution has three parts: use a cookie to prevent double votes store all vote events in the database (ip, user agent, poll/article id, vote) implement an algorithm which will run every 24h to delete the double votes which escaped from #1. The algo will use data from #2 Using only the IP is not appropriate as it can leave tons of people out of the voting