I''am creating a pollsystem for my site. so on each vote in the database the ip adress of the person that vote is logged. But how can i make that when somebody vote this ip adress not voted before. So how can i compare the list of ip adresses with the new one -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I am unsure what you mean. But what I would do is drop a cookie with a (semi) unique number and store that number in a database. Unless it is _very_ important users can''t vote more than once. The problem with logging IP''s is that there could be more than one PC behind a single IP. And this is quite often the case. If a user comes to your site you simple retrieve the cookie with the number and see if the number already exists in the DB, if so the person already voted, if not he did not. On Jul 25, 3:38 pm, GA Gorter <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''am creating a pollsystem for my site. > so on each vote in the database the ip adress of the person that vote is > logged. > But how can i make that when somebody vote this ip adress not voted > before. > > So how can i compare the list of ip adresses with the new one > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 25 Jul 2007, at 15:38, GA Gorter wrote:> I''am creating a pollsystem for my site. > so on each vote in the database the ip adress of the person that > vote is > logged. > But how can i make that when somebody vote this ip adress not voted > before. > > So how can i compare the list of ip adresses with the new oneHow about something like (code can be made shorter, but I''ll keep it nice and easy to understand): if Vote.find(:first, :conditions => ["ip_address = ? and poll_id = ?", request.remote_ip, params[:poll_id]]) flash[:notice] = "You''ve voted for this poll already" # Do a redirect, reder or render something using AJAX else new_vote = Vote.new(params[:vote]) new_vote.ip_address = request.remote_ip assigned_poll = Poll.find(params[:poll_id]) assigned_poll << new_vote if assigned_poll && new_vote.valid? # Do a redirect, render or render something using AJAX end Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 25 Jul 2007, at 16:26, harm wrote:> I am unsure what you mean. But what I would do is drop a cookie with a > (semi) unique number and store that number in a database. Unless it is > _very_ important users can''t vote more than once. The problem with > logging IP''s is that there could be more than one PC behind a single > IP. And this is quite often the case. > > If a user comes to your site you simple retrieve the cookie with the > number and see if the number already exists in the DB, if so the > person already voted, if not he did not.I would combine the two and even store the vote in a session variable for extra security if users have to log in to vote (it all depends on how important the unique votes are). Simply said: internet voting can always be tampered with: * People can change their IP (most ISPs use DHCP, so resetting the modem gives your user a new IP) * People can delete cookies * People can quit their browser, thus resetting the session The more security you put in place, the more you''re disencouraging your user search for a way to cast additional votes. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the code Harm my site is working very well now. @peter That''s true it''s very simple to have another ip adres my neigbors have an unprotected wireless network. But this was a project just for fun. Now i have a pollcode i think i will make it better and intergrate in some of my other projects. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---