Q:

skip_before_filter doesn't actually skip

So, i have model User
class User < ActiveRecord::Base
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  attr_accessible :email, :password, :password_confirmation, :remember_me
end

I've created scaffold to that model using rails generators, in controller i added following lines:
class UsersController < ApplicationController
  before_filter :authenticate_user!

  skip_before_filter :require_no_authentication, :only => [:create]

  # ...
end

Finally, when I'm trying to create user I've got this:
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)

So, according to log skip_before_filter didn't work. What am I doing wrong?

EDIT: I don't want give possibility to create user when someone isn't logged in, so skipping :authenticate_user! isn't option. btw. registerable is only temporary in User model.

A:

You need to apply the changes to the right controller, in this case Devise::RegistrationsController. Simply extend it like this (not tested, but the principle should work):
# app/controllers/registration_controller.rb
class RegistrationsController < Devise::RegistrationsController
  skip_before_filter :require_no_authentication, :only => [:create]
end

and make sure Devise uses that:
# routes.rb
devise_for :users, :controllers => { :registrations => "registrations" }

You can search the excellent Devise Wiki for many examples on extending Devise's controllers.

