This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def vote | |
if !@hairstyle = Hairstyle.find_by_id(params[:id]) | |
redirect_to root_url, notice: 'Please select at least one hairstyle' | |
else | |
@client_ip = request.remote_ip | |
blacklist = Blacklist.find_by_ip(@client_ip) | |
if blacklist.try(:ip) == @client_ip | |
redirect_to root_url, notice: 'Looks like you\'ve voted recently, come back in 24hrs.' | |
else | |
if @hairstyle = Hairstyle.find_by_id(params[:id]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started POST "/hairstyles/vote" for 127.0.0.1 at 2012-09-17 16:14:01 -0700 | |
Processing by HairstylesController#vote as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"t/Km9bYCNZWFcebozXqmVB2Gpta1C8W07l0kqkiLjS0=", "id"=>"6", "commit"=>"Vote"} | |
Redirected to http://hairapp.dev/hairstyles/vote?id=6 | |
Filter chain halted as :ip_check rendered or redirected | |
Completed 302 Found in 1ms (ActiveRecord: 0.0ms) | |
Started GET "/hairstyles/vote?id=6" for 127.0.0.1 at 2012-09-17 16:14:01 -0700 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started POST "/hairstyles/vote" for 127.0.0.1 at 2012-09-17 16:00:51 -0700 | |
Processing by HairstylesController#vote as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"t/Km9bYCNZWFcebozXqmVB2Gpta1C8W07l0kqkiLjS0=", "hairstyle"=>"6", "commit"=>"Vote"} | |
[1m[35mHairstyle Load (0.2ms)[0m SELECT "hairstyles".* FROM "hairstyles" WHERE "hairstyles"."id" = ? LIMIT 1 [["id", "6"]] | |
Redirected to http://hairapp.dev/hairstyles/vote?hairstyle=6 | |
Filter chain halted as :ip_check rendered or redirected | |
Completed 302 Found in 8ms (ActiveRecord: 0.6ms) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started POST "/hairstyles/vote" for 127.0.0.1 at 2012-09-17 15:59:04 -0700 | |
Processing by HairstylesController#vote as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"t/Km9bYCNZWFcebozXqmVB2Gpta1C8W07l0kqkiLjS0=", "hairstyle"=>"6", "commit"=>"Vote"} | |
[1m[35mHairstyle Load (0.1ms)[0m SELECT "hairstyles".* FROM "hairstyles" WHERE "hairstyles"."id" = ? LIMIT 1 [["id", "6"]] | |
[1m[36m (0.1ms)[0m [1mbegin transaction[0m | |
[1m[35mHairstyle Exists (0.1ms)[0m SELECT 1 AS one FROM "hairstyles" WHERE ("hairstyles"."name" = 'Let It Grow' AND "hairstyles"."id" != 6) LIMIT 1 | |
[1m[36m (0.3ms)[0m [1mUPDATE "hairstyles" SET "count" = 10, "updated_at" = '2012-09-17 22:59:04.575039' WHERE "hairstyles"."id" = 6[0m | |
[1m[35m (2.5ms)[0m commit transaction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_tag(:controller => 'hairstyles', :action => 'vote') do %> | |
<% Hairstyle.all.each do |hairstyle| %> | |
<ul style="float:left;"> | |
<li><%= radio_button_tag 'id', hairstyle.id %></li> | |
<li class="name"><%= hairstyle.name %></li> | |
<li class="count"><%= hairstyle.count %></li> | |
</ul> | |
<% end %> | |
<%= submit_tag 'Vote' %> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HairstylesController < ApplicationController | |
before_filter :ip_check, :only => [:vote] | |
def vote | |
if @hairstyle = Hairstyle.find(params[:id]) | |
@hairstyle.increment('count') | |
@hairstyle.save | |
redirect_to root_url, notice: 'Thanks for Voting' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row-fluid" id="hairstyles"> | |
<%= form_tag('/blacklists/ip_check') do %> | |
<% Hairstyle.all.each do |hairstyle| %> | |
<ul style="float:left;"> | |
<li><%= radio_button_tag 'hairstyle', hairstyle.id %></li> | |
<li class="name"><%= hairstyle.name %></li> | |
<li class="count"><%= hairstyle.count %></li> | |
</ul> | |
<% end %> | |
<%= submit_tag 'Vote' %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ --> | |
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> | |
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--> | |
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]--> | |
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]--> | |
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> | |
<head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ --> | |
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> | |
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--> | |
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]--> | |
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]--> | |
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> | |
<head> |
NewerOlder