Permalink
Browse files

captcha en los comentarios

  • Loading branch information...
1 parent 4639e52 commit 53a92e8aad9d51bfeea951b5d9cada5989c225d3 @jparbros committed Mar 13, 2012
View
1 Gemfile
@@ -25,6 +25,7 @@ gem 'mime'
gem 'ruby-gmail', :require => 'gmail'
gem 'mail'
gem 'typhoeus'
+gem "recaptcha", :require => "recaptcha/rails"
group :assets do
gem 'coffee-rails', '~> 3.1.1'
View
2 Gemfile.lock
@@ -168,6 +168,7 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
+ recaptcha (0.3.4)
redis (2.2.2)
redis-namespace (1.0.3)
redis (< 3.0.0)
@@ -286,6 +287,7 @@ DEPENDENCIES
pg
rails (= 3.1.3)
rails-i18n
+ recaptcha
resque
resque-scheduler
ruby-debug19
View
4 app/controllers/comentarios_controller.rb
@@ -1,11 +1,11 @@
class ComentariosController < ApplicationController
def create
@representante = Representative.find(params[:congresista_id])
- if @representante.comments.create_approved(params[:comment])
+ if verify_recaptcha && @representante.comments.create_approved(params[:comment])
redirect_to :back, :notice => "Comentario creado exitosamente"
else
redirect_to :back, :alert => "Comentario fallo al crearse"
end
end
-
+
end
View
2 app/views/congresistas/show.html.haml
@@ -78,6 +78,8 @@
= form.text_area :comment, :placeholder => 'Mensaje', :class => 'span7 input-text', 'data-len' => 500
+ = recaptcha_tags
+
= hidden_field_tag :other_email
= submit_tag 'comenta', :class => 'submit span4'
View
4 config/initializers/recaptcha.rb
@@ -0,0 +1,4 @@
+Recaptcha.configure do |config|
+ config.public_key = '6Let2s4SAAAAAHtbaAMgFjpt_lUoAAY3K7xRCDek'
+ config.private_key = '6Let2s4SAAAAAK9REP_gcsCQeqtMC-7ET-q_U5QQ'
+end

0 comments on commit 53a92e8

Please sign in to comment.