valida la casilla de verificación de aceptación de los términos y la conexión de Facebook

How can you force terms and condition acceptance whith facebook connect ?

In my OmniauthCallbacksController i tried

@user_ipad.terms = true

Validation of the User still fails and the user gets redirected to the sign_up form with an error message.

/app/controllers/OmniauthCallbacksController

      @user_ipad = UserIpad.new(:password => Devise.friendly_token[0,20])
      @user_ipad.update_with_facebook_infos(omniauth)
      @user_ipad.authentication_ways.build(:provider => omniauth['provider'], :uid => omniauth['uid'])
      @user_ipad.terms = true

      if @user_ipad.save()
        sign_in_and_redirect @user_ipad, :event => :authentication
      else
        session["devise.facebook_data"] = omniauth
        render :action=>'new', :controller=>'user_ipads', :layout => 'empty_layout'
      end

/app/models/User

  attr_accessible :terms
  ...
  validates_acceptance_of :terms, :allow_nil => false, :message => "Vous devez accepter les conditions générales d'utilisation", :on => :create

Gracias por tu ayuda, Vincent.

preguntado el 09 de marzo de 12 a las 17:03

1 Respuestas

validates_acceptance_of has an "accept" option. Rails doc says :

:accept - Specifies value that is considered accepted. The default value is a string “1”, which makes it easy to relate to an HTML checkbox. This should be set to true if you are validating a database column, since the attribute is typecast from “1” to true before validation.

So in your case, you should replace

@user_ipad.terms = true

con :

@user_ipad.terms = "1"

respondido 10 mar '12, 14:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.