Rails sorcery 新規登録ができない

 解決:view file 

form_for を<table> タグ内部でなく 外部にして、tableタグを囲む。 

コントローラー:

class RegistrationsController < ApplicationController
def new
@user = User.new
end

def create
@user = User.new(params_user)
if @user.save
raise
login(:email, :password)
redirect_to questions_path
else
render :new
end
end

private
def params_user
params.require(:user).permit(:screen_name, :email, :password, :password_confirmation, :status, :child_age1, :child_age2, :residence_country, :residencenow, :school, :origin, :wannaknow, :know, :bio, :mailmagazine, :comment, :privacy)
end
end

-----------------------------------------

ビューファイル:

%table
%tbody
= form_for @user, url: registrations_path, method: :post do |f|
%tr
%td.alignright
メールアドレス*:
%td
= f.text_field :email, :placeholder => "example@example.com"
%tr
%td.alignright
表示名(小文字・半角のみ)*:
%td
= f.text_field :screen_name, :placeholder => "4~24文字 半角"
%tr
%td.alignright 立場*:
%td.radio
=f.radio_button :status, "保護者"
.text
保護者
%tr
%td.alignright
%td.radio
=f.radio_button :status, "IB生の保護者"
.text
IB生の保護者
%tr
%td.alignright
%td.radio
=f.radio_button :status, "教育関係者"
.text
教員/教育関係者
%tr
%td.alignright
%td.radio
=f.radio_button :status, "IB教員"
.text
IB教員
%tr
%td.alignright
%td.radio
=f.radio_button :status, "IB生/卒業生"
.text
IB生/卒業生
%tr
%td.alignright
%td.radio
=f.radio_button :status, "生徒"
.text
生徒
%tr
%td.alignright
お子様の年齢:
%td
= f.text_field :child_age1, :class => "child_age"
%tr
%td.alignright
在住国*:
%td
= f.text_field :residence_country, :placeholder => "(例)日本"
%tr
%td.alignright
都道府県/地域*:
%td
= f.text_field :residencenow, :placeholder => "(例)東京都"
%tr
%td.alignright
学校名:
%td
= f.text_field :school, :placeholder => "学校名(非公開)"
%tr
%td.alignright
ほかに知っている地域:
%td
= f.text_field :origin, :placeholder => "(例)アメリカ"
%tr
%td.alignright
知りたい分野*:
%td
= f.text_area :wannaknow, :placeholder => "高校進路、英語、家庭学習などなど"
%tr
%td.alignright
答えられる分野:
%td
= f.text_area :know, :placeholder => "みなさまの力が必要です!"
%tr
%td.alignright
自己紹介:
%td
= f.text_area :bio, size: "20"
.space10px
.space10px
/ %tr
/ %td.alignright
/ 質問記録の公開:
/ %td.checkbox
/ = f.check_box :privacy, {checked: "checked"}, true, false
/  サイト内公開
/ %tr
/ %td.alignright
/ メールマガジン
/ %td.checkbox
/ = f.check_box :mailmagazine, {checked: "checked"}, true, false
/  受け取る
/ %tr
/ %td.alignright
/ .space10px
/ .space10px
/ %td

%tr
%td.alignright
パスワード*:
%td
= f.password_field :password
%tr
%td.alignright
パスワード(確認)*:
%td
= f.password_field :password_confirmation
%tr
%td.alignright
%td.float
= f.submit '登録', :class => "btn btn-default submitbutton float_right"

---------------------------------------

routes.rb:

Rails.application.routes.draw do

resource :registrations, only: [:new, :create]
resource :sessions, only: [:new, :create, :destroy]
resource :settings, only: [:edit, :update]

resources :users, only: [:index, :show]
# get '/users/:id' => 'users#show'
# get '/users' => 'users#index'


resources :categories
get "/questions", to: "questions#index"
get "/questions/category", to: "questions#index_category"

resources :questions do
resource :favorites, only: [:create, :destroy]
resources :answers
end

get 'slides/show'


root to: 'questions#index'

------------------------

iTerm2:


Started GET "/registrations/new" for ::1 at 2015-04-09 16:50:42 +0900
Processing by RegistrationsController#new as HTML
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
Rendered questions/_header.html.haml (2.1ms)
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1

 

 

 

成功(if @user.save からのraiseまできた)した時のログ:


Started POST "/registrations" for ::1 at 2015-04-09 17:01:54 +0900
Processing by RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"8JE6CfiTZB1TtH5bZxO6D27T3krrbh2sJPecyNEX4xEVwVLpE7gOikCEaVuSCsdeMyDW89NZThuHznP7VPRgow==", "user"=>{"email"=>"erfgggh", "screen_name"=>"eeeeefwe", "status"=>"保護者", "child_age1"=>"", "residence_country"=>"weff", "residencenow"=>"ewf", "school"=>"", "origin"=>"", "wannaknow"=>"wef", "know"=>"", "bio"=>"", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"登録"}
(0.2ms) begin transaction
User Exists (0.9ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."screen_name") = LOWER('eeeeefwe') LIMIT 1
User Exists (0.5ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER('erfgggh') LIMIT 1
SQL (1.5ms) INSERT INTO "users" ("screen_name", "email", "status", "residence_country", "residencenow", "school", "origin", "wannaknow", "know", "bio", "salt", "crypted_password", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["screen_name", "eeeeefwe"], ["email", "erfgggh"], ["status", "保護者"], ["residence_country", "weff"], ["residencenow", "ewf"], ["school", ""], ["origin", ""], ["wannaknow", "wef"], ["know", ""], ["bio", ""], ["salt", "kk1rm8mbH4zLVkxRjYZ9"], ["crypted_password", "$2a$10$wipae42ajPvwuExOvTGm2uvQeuVihY4CCHZM4etqtn0vYyfoQzpdi"], ["created_at", "2015-04-09 08:01:54.613465"], ["updated_at", "2015-04-09 08:01:54.613465"]]
(1.1ms) commit transaction
Completed 500 Internal Server Error in 197ms (ActiveRecord: 4.1ms)

RuntimeError - :
app/controllers/registrations_controller.rb:9:in `create'
actionpack (4.2.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.1) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.1) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
activesupport (4.2.1) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:776:in `_run_process_action_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.1) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.1) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.1) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.1) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:43:in `serve'
actionpack (4.2.1) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.1) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:819:in `call'
rack (1.6.0) lib/rack/etag.rb:24:in `call'
rack (1.6.0) lib/rack/conditionalget.rb:38:in `call'
rack (1.6.0) lib/rack/head.rb:13:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:649:in `call'
activerecord (4.2.1) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.1) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:776:in `_run_call_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.1.2) lib/web_console/middleware.rb:37:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.0) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
railties (4.2.1) lib/rails/engine.rb:518:in `call'
railties (4.2.1) lib/rails/application.rb:164:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
rack (1.6.0) lib/rack/content_length.rb:15:in `call'
rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service'
/Users/HOkaniwa/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/Users/HOkaniwa/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/Users/HOkaniwa/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'