0

Edit: thanks @vinodadhikary -- upon further investigation it seems that the error happens when a) the email is not unique, b) the name is not unique or c) the email is obviously fake (h@h.com). If Devise isn't going to accept a signup I would prefer the errors to happen gracefully. The error handling is correct if passwords don't match or a field isn't complete. Also, non-unique names shouldn't be a problem? Is this caused by the creation of slugs (using name as the slug) with FriendlyID?

Original: I'm getting a strange error on my Devise signup when someone signs up when one of the conditions above is met for a signup. I don't think I've done anything outside the realm of normalcy for a Devise installation (used Rails Composer, if it matters). Thanks in advance for any help...

Here is the error:

SQLite3::ConstraintException: constraint failed: INSERT INTO "users"
("avatar_content_type", "avatar_file_name", "avatar_file_size", "avatar_updated_at", 
"confirmation_sent_at", "confirmation_token", "confirmed_at", "created_at",     
"current_sign_in_at", "current_sign_in_ip", "email", "encrypted_password", 
"fully_registered", "last_sign_in_at", "last_sign_in_ip", "name", "remember_created_at", 
"reset_password_sent_at", "reset_password_token", "sign_in_count", "slug", 
"unconfirmed_email", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, ?)

工夫/登録/new.html.haml:

%section.row-fluid.sign-up
  .container-fluid
    .span6.landing-left
      %h1 Sign Up!
      .form-inputs
        = simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-vertical' }) do |f|
          = f.error_notification
          = display_base_errors resource
          = f.input :name, :autofocus => true, :placeholder => "Your Name", label: false
          = f.input :email, :required => true, :placeholder => "Your Email", label: false
          = f.input :password, :required => true, :placeholder => "Password", label: false
          = f.input :password_confirmation, :required => true, :placeholder => "Password Confirmation", label: false
          = f.button :submit, 'Join L', :class => 'btn button'
      %p
        = link_to "or, Sign In", new_user_session_url

ユーザー.rb:

class User < ActiveRecord::Base
  rolify

  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :confirmable

  after_create :assign_default_role

  # Setup accessible (or protected) attributes for your model
  attr_accessible :role_ids, :as => :admin
  attr_accessible :name, :email, :password, :password_confirmation, :remember_me, :fully_registered, :avatar

  has_one :profile, dependent: :destroy

  has_many :appointments, foreign_key: "host_id"
  has_many :appointments, foreign_key: "attendee_id"

  has_many :reviews, foreign_key: "reviewee_id"
  has_many :reviewed_users, foreign_key: "reviewer_id", class_name: "Review"

  validates_attachment :avatar,
                          content_type: { content_type: ['image/jpeg', 'image/jpg', 'image/png', 'image/gif'] },
                          size: { less_than: 1.megabytes }


  extend FriendlyId
  friendly_id :name, use: [:slugged, :history]

  has_attached_file :avatar, styles: {
    thumb: '100x100>',
    square: '200x200#',
    medium: '300x300>'
  }, default_url: 'https://s3.amazonaws.com/l/layout/elements/placeholders/image_placeholder.svg'


  def get_review_score
    reviews.average('rating').to_f
  end

  protected

  # def confirmation_required?
  #   false
  # end

  def assign_default_role
    # Default Role: User, ID: 2
    add_role(:user)
  end

end

完全なスタック トレース:

Started POST "/users" for 127.0.0.1 at 2013-07-17 19:20:23 -0400
Processing by Devise::RegistrationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"Vl2A8qW8GLCF7elJIQkw4FCBcRd7Oaz1O9yJth3Wg6g=", "user"=>{"name"=>"Henry", "email"=>"h.h@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Join L"}
   (0.1ms)  begin transaction
  FriendlyId::Slug Load (0.3ms)  SELECT "friendly_id_slugs".* FROM "friendly_id_slugs" WHERE "friendly_id_slugs"."sluggable_type" = 'User' AND (slug = 'henry' OR slug LIKE 'henry--%') ORDER BY LENGTH(slug) DESC, slug DESC LIMIT 1
  User Exists (0.1ms)  SELECT 1 AS one FROM "users" WHERE "users"."email" = 'h.h@gmail.com' LIMIT 1
  User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."confirmation_token" = 'W6sjj2MZ1wxqxEfrFxYM' LIMIT 1
Binary data inserted for `string` type on column `encrypted_password`
  SQL (1.0ms)  INSERT INTO "users" ("avatar_content_type", "avatar_file_name", "avatar_file_size", "avatar_updated_at", "confirmation_sent_at", "confirmation_token", "confirmed_at", "created_at", "current_sign_in_at", "current_sign_in_ip", "email", "encrypted_password", "fully_registered", "last_sign_in_at", "last_sign_in_ip", "name", "remember_created_at", "reset_password_sent_at", "reset_password_token", "sign_in_count", "slug", "unconfirmed_email", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)  [["avatar_content_type", nil], ["avatar_file_name", nil], ["avatar_file_size", nil], ["avatar_updated_at", nil], ["confirmation_sent_at", Wed, 17 Jul 2013 19:20:23 EDT -04:00], ["confirmation_token", "W6sjj2MZ1wxqxEfrFxYM"], ["confirmed_at", nil], ["created_at", Wed, 17 Jul 2013 19:20:23 EDT -04:00], ["current_sign_in_at", nil], ["current_sign_in_ip", nil], ["email", "h.h@gmail.com"], ["encrypted_password", "$2a$10$4XffwFcxoq4a8bDvUTvTauZNkUkKB/KgY.FZU4pxOH.pLmkL/JGvi"], ["fully_registered", false], ["last_sign_in_at", nil], ["last_sign_in_ip", nil], ["name", "Henry"], ["remember_created_at", nil], ["reset_password_sent_at", nil], ["reset_password_token", nil], ["sign_in_count", 0], ["slug", "henry--2"], ["unconfirmed_email", nil], ["updated_at", Wed, 17 Jul 2013 19:20:23 EDT -04:00]]
SQLite3::ConstraintException: constraint failed: INSERT INTO "users" ("avatar_content_type", "avatar_file_name", "avatar_file_size", "avatar_updated_at", "confirmation_sent_at", "confirmation_token", "confirmed_at", "created_at", "current_sign_in_at", "current_sign_in_ip", "email", "encrypted_password", "fully_registered", "last_sign_in_at", "last_sign_in_ip", "name", "remember_created_at", "reset_password_sent_at", "reset_password_token", "sign_in_count", "slug", "unconfirmed_email", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
   (0.1ms)  rollback transaction
Completed 500 Internal Server Error in 81ms

ActiveRecord::StatementInvalid - SQLite3::ConstraintException: constraint failed: INSERT INTO "users" ("avatar_content_type", "avatar_file_name", "avatar_file_size", "avatar_updated_at", "confirmation_sent_at", "confirmation_token", "confirmed_at", "created_at", "current_sign_in_at", "current_sign_in_ip", "email", "encrypted_password", "fully_registered", "last_sign_in_at", "last_sign_in_ip", "name", "remember_created_at", "reset_password_sent_at", "reset_password_token", "sign_in_count", "slug", "unconfirmed_email", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?):
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract_adapter.rb:285:in `rescue in log'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
  activerecord (3.2.13) lib/active_record/connection_adapters/sqlite_adapter.rb:242:in `exec_query'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract/database_statements.rb:63:in `exec_insert'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
  activerecord (3.2.13) lib/active_record/relation.rb:66:in `insert'
  activerecord (3.2.13) lib/active_record/persistence.rb:367:in `create'
  activerecord (3.2.13) lib/active_record/timestamp.rb:58:in `create'
  activerecord (3.2.13) lib/active_record/callbacks.rb:268:in `block in create'
  activesupport (3.2.13) lib/active_support/callbacks.rb:414:in `_run__2609459987145809617__create__3448311305093244115__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  activerecord (3.2.13) lib/active_record/callbacks.rb:268:in `create'
  activerecord (3.2.13) lib/active_record/persistence.rb:348:in `create_or_update'
  activerecord (3.2.13) lib/active_record/callbacks.rb:264:in `block in create_or_update'
  activesupport (3.2.13) lib/active_support/callbacks.rb:425:in `_run__2609459987145809617__save__3448311305093244115__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  activerecord (3.2.13) lib/active_record/callbacks.rb:264:in `create_or_update'
  activerecord (3.2.13) lib/active_record/persistence.rb:84:in `save'
  activerecord (3.2.13) lib/active_record/validations.rb:50:in `save'
  activerecord (3.2.13) lib/active_record/attribute_methods/dirty.rb:22:in `save'
  activerecord (3.2.13) lib/active_record/transactions.rb:259:in `block (2 levels) in save'
  activerecord (3.2.13) lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
  activerecord (3.2.13) lib/active_record/transactions.rb:208:in `transaction'
  activerecord (3.2.13) lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
  activerecord (3.2.13) lib/active_record/transactions.rb:259:in `block in save'
  activerecord (3.2.13) lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
  activerecord (3.2.13) lib/active_record/transactions.rb:258:in `save'
  devise (2.2.4) app/controllers/devise/registrations_controller.rb:15:in `create'
  actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.13) lib/active_support/callbacks.rb:436:in `_run__1922468707363096533__process_action__814005644436315713__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
  actionpack (3.2.13) lib/action_dispatch/routing/mapper.rb:42:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
  warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.1) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.5) lib/rack/etag.rb:23:in `call'
  rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
  rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
  activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__2361827533017433596__call__3448311305093244115__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:56:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
  activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
  railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
  quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
  actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.5) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.5) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
  railties (3.2.13) lib/rails/engine.rb:479:in `call'
  railties (3.2.13) lib/rails/application.rb:223:in `call'
  rack (1.4.5) lib/rack/content_length.rb:14:in `call'
  railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
  rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
  /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
  /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
  /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'



Started POST "/__better_errors/70311741936300/variables" for 127.0.0.1 at 2013-07-17 19:20:23 -0400
4

1 に答える 1