NoMethodError in User sessionsController#create - Authlogic

Hi,
I’m beginner in rails, and I wanted to add to my simple application
Authlogic. So I’ve watched #160 Authlogic - RailsCasts
and step-by-step done everything. And almost everything works fine,
except login in. After registration new user is automatically logged in,
he can edit his profile, but after clicking logout and trying to login
again I get error

NoMethodError in User sessionsController#create

undefined method `mb_chars’ for “rzepak”:String

My user_session_controller.rb:

class UserSessionsController < ApplicationController
def new
@user_session = UserSession.new
end

def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = “Successfully logged in.”
redirect_to root_url
else
render :action => ‘new’
end
end

def destroy
current_user_session.destroy
flash[:notice] = “Successfully logged out.”
redirect_to root_url
end

end

I was trying to google this error, but with no success, so I hope I will
find some help here

gem -v 1.3.5
ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

On Aug 2, 10:01 am, “Rzepak G.” [email protected]
wrote:

undefined method `mb_chars’ for “rzepak”:String
if @user_session.save
redirect_to root_url
end

end

I was trying to google this error, but with no success, so I hope I will
find some help here

gem -v 1.3.5
ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

You didn’t post your view, but, maybe a typo via “User
sessionsController”?

it’s just
user_sessions - new.html.erb
<% title “Login” %>

<% form_for @user_session do |f| %>
<%= f.error_messages %>

<%= f.label :username %>
<%= f.text_field :username %>

<%= f.label :password %>
<%= f.password_field :password %>

<%= f.submit "Submit" %>

<% end %>

and it was created automatically… i didn’t change to much in code…

Hmm, it looks strange, but I’ve checked all files and there’s no typo, I
even overwrite some code with code from screencast post, but still
there’s the same bug.
I think it’s connected with
“undefined method `mb_chars’ for “rzepak”:String”
but I don’t know what to do with it

vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/login.rb:121:in
find_with_case' vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/login.rb:110:infind_by_smart_case_login_field’
vendor/plugins/authlogic/lib/authlogic/session/scopes.rb:95:in send' vendor/plugins/authlogic/lib/authlogic/session/scopes.rb:95:insearch_for_record’
vendor/rails/activerecord/lib/active_record/base.rb:1852:in with_scope' vendor/plugins/authlogic/lib/authlogic/session/scopes.rb:94:insend’
vendor/plugins/authlogic/lib/authlogic/session/scopes.rb:94:in
search_for_record' vendor/plugins/authlogic/lib/authlogic/session/password.rb:178:invalidate_by_password’
vendor/rails/activesupport/lib/active_support/callbacks.rb:173:in send' vendor/rails/activesupport/lib/active_support/callbacks.rb:173:inevaluate_method’
vendor/rails/activesupport/lib/active_support/callbacks.rb:161:in call' vendor/rails/activesupport/lib/active_support/callbacks.rb:93:inrun’
vendor/rails/activesupport/lib/active_support/callbacks.rb:92:in each' vendor/rails/activesupport/lib/active_support/callbacks.rb:92:insend’
vendor/rails/activesupport/lib/active_support/callbacks.rb:92:in run' vendor/rails/activesupport/lib/active_support/callbacks.rb:272:inrun_callbacks’
vendor/plugins/authlogic/lib/authlogic/session/callbacks.rb:71:in
validate' vendor/plugins/authlogic/lib/authlogic/session/validation.rb:62:invalid?’
vendor/plugins/authlogic/lib/authlogic/session/existence.rb:65:in save' app/controllers/user_sessions_controller.rb:8:increate’

Hi, I had the same issue - I think it has something to do with the
latest version of Authlogic possibly requiring Ruby 1.9???, whereas
I’m running 1.8.6 on my dev machine and I see you’re running 1.8.7.

The commit 53834196c8f82cac6b105126e3d267246b7b2b67 from July 2, 2009
seems to be the issue:
Use mb_chars when downcasing login to deal with international
characters

Specifying the previous gem version in my Rails environment seemed to
do the trick:
config.gem ‘authlogic’, :version => “= 2.1.0”

Let me know how it goes.

On Aug 3, 4:34 am, “Rzepak G.” [email protected]

I wrote an app today that used authlogic 2.1.1 on ruby 1.8.6 just
fine.

-eric

Adam Hill wrote:

Hi, I had the same issue - I think it has something to do with the
latest version of Authlogic possibly requiring Ruby 1.9???, whereas
I’m running 1.8.6 on my dev machine and I see you’re running 1.8.7.

The commit 53834196c8f82cac6b105126e3d267246b7b2b67 from July 2, 2009
seems to be the issue:
Use mb_chars when downcasing login to deal with international
characters

Specifying the previous gem version in my Rails environment seemed to
do the trick:
config.gem ‘authlogic’, :version => “= 2.1.0”

Let me know how it goes.

On Aug 3, 4:34�am, “Rzepak G.” [email protected]

I had the same error. authlogic version 2.1.0 didn’t help. Changing
rails version from 2.1.0 to 2.3.3 did. I’m using Ruby 1.8.6.

On Aug 2, 11:14 am, “Rzepak G.” [email protected]
wrote:

<%= f.label :password %>
<%= f.password_field :password %>

<%= f.submit "Submit" %>

<% end %>

and it was created automatically… i didn’t change to much in code…

Posted viahttp://www.ruby-forum.com/.

OK, but do you see anything strange about:

“User sessionsController”?

I’m having the same problem when using both a login field and an email
field. I get the no method error for the email field in any view. If I
remove the login field from the migration and the views all works fine.

Im on rails 2.3.3 and ruby 1.8.7

I just installed the latest plugin and disabled the gem as suggested in
Ben’s google group but no joy.

Still looking for an answer…

Eric

amit_pandya wrote:

This things happens because of version conflict of authlogic, either
upgrade or remove current one and install old one

Adam Hill wrote:

Hi, I had the same issue - I think it has something to do with the
latest version of Authlogic possibly requiring Ruby 1.9???, whereas
I’m running 1.8.6 on my dev machine and I see you’re running 1.8.7.

The commit 53834196c8f82cac6b105126e3d267246b7b2b67 from July 2, 2009
seems to be the issue:
Use mb_chars when downcasing login to deal with international
characters

Specifying the previous gem version in my Rails environment seemed to
do the trick:
config.gem ‘authlogic’, :version => “= 2.1.0”

Let me know how it goes.

On Aug 3, 4:34�am, “Rzepak G.” [email protected]

On Aug 22, 11:00 pm, No Where [email protected]
wrote:

I’m having the same problem when using both a login field and an email
field. I get the no method error for the email field in any view. If I
remove the login field from the migration and the views all works fine.

Im on rails 2.3.3 and ruby 1.8.7

I just installed the latest plugin and disabled the gem as suggested in
Ben’s google group but no joy.

Still looking for an answer…
Is this issue still pending? No fix for the ruby 1.8.7 users?

Hai,
I am getting this type of error while connecting my application with
facebook
Please help me to fin solution for my problem

NoMethodError in SessionsController#new

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.+

On 23 May 2011 10:49, flower g. [email protected] wrote:

The error occurred while evaluating nil.+
This is nothing to do with the original subject of this thread. I
suggest starting a new thread with an appropriate subject. First
however examine the error message carefully and try and work out what
it means. There should be a stack trace showing which line the error
appeared on.

Colin