だから、私はモデルユーザーを持っています
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me
end
レールジェネレーターを使用してそのモデルに足場を作成しました。コントローラーに次の行を追加しました。
class UsersController < ApplicationController
before_filter :authenticate_user!
skip_before_filter :require_no_authentication, :only => [:create]
# ...
end
最後に、ユーザーを作成しようとすると、次のようになります。
Started POST "/users" for 127.0.0.1 at 2012-12-13 22:33:34 +0100
Processing by Devise::RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"wkJ8ZxVUg9eaFiL+Guu+QIfjGiwGANReiv2bTu3YQPg=", "user"=>{"email"=>"test@test.pl", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Save"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Redirected to http://localhost:3000/
Filter chain halted as :require_no_authentication rendered or redirected
Completed 302 Found in 2ms (ActiveRecord: 0.3ms)
したがって、ログによると、skip_before_filterは機能しませんでした。私は何が間違っているのですか?
編集:誰かがログインしていないときにユーザーを作成する可能性を与えたくないので、:authenticate_userをスキップしてください!オプションではありません。ところで。登録可能は、ユーザーモデルでは一時的なものです。