# Strange error while using Authlogic

**URL:** <https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689>\
**Category:** rubyonrails-talk\
**Created:** [November 13, 2010, 9:49am UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689 "2010-11-13T09:49:40Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Konstantinos\_Loupos](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Konstantinos\_Loupos](https://discuss.rubyonrails.org/u/Konstantinos_Loupos)\
**Post date:** [November 13, 2010, 9:49am UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/1 "2010-11-13T09:49:40Z")

</div>

Hi to all, i have installed authlogic as shown in this tutorial [DIXIS authlogic on rails3](http://www.dixis.com/?p=352). The fields i have used are t\_login, t\_password, t\_name, t\_password\_salt, t\_persistence\_token.

When i go to home#index, i get this error:

NameError in HomeController#index

uninitialized constant Authlogic ... Application Trace | Framework Trace | Full Trace app/models/user\_session.rb:1 app/controllers/application\_controller.rb:10:in `current_user_session' app/controllers/application_controller.rb:16:in `current\_user' app/controllers/application\_controller.rb:21:in `require\_user' ....

Do you know what this comes from???

Thank you in advance Kostas L.

---

<div class="post-metadata">

**Author:** ![Konstantinos\_Loupos](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Konstantinos\_Loupos](https://discuss.rubyonrails.org/u/Konstantinos_Loupos)\
**Post date:** [November 21, 2010, 7:12pm UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/2 "2010-11-21T19:12:40Z")

</div>

Anyone??? Any ideas??? I really cant find a sollution in the web...

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [November 21, 2010, 7:55pm UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/3 "2010-11-21T19:55:31Z")

</div>

Uninitialized constant usually means that the the module hasn't been loaded into the Rails environment. Adding an initializer file might fix it, but it seems to me that this shouldn't be necessary with Authlogic. Make sure you're using the most updated version of Authlogic.

# config/initializers/authlogic.rb require ' authlogic'

---

<div class="post-metadata">

**Author:** ![Konstantinos\_Loupos](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Konstantinos\_Loupos](https://discuss.rubyonrails.org/u/Konstantinos_Loupos)\
**Post date:** [November 26, 2010, 9:03pm UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/4 "2010-11-26T21:03:44Z")

</div>

Hi, i have installed Authlogic using gem "authlogic" in the gemfile. I also run bundle install and i did not got an error.

I have created an new application from scratch and now i get the following error: NoMethodError in User\_sessions#new

Showing G:/.../AuthlogicTest/app/views/user\_sessions/new.html.erb where line #6 raised:

Model UserSession does not respond to t\_login Extracted source (around line #6):

3: \<%= form\_for @user\_session, :url =\> {:action =\> "create"} do |f|%\> 4: \<%= f.error\_messages%\> 5: \<%= f.label :t\_login%\> 6: \<%= f.text\_field :t\_login%\> 7: \<%= f.label :t\_password%\> 8: \<%= f.password\_field :t\_password%\> 9: \<%div%\>

I havent found a sollution yet......

Any ideas?? Thank you again

---

<div class="post-metadata">

**Author:** ![Colin\_Law1](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@Colin\_Law1](https://discuss.rubyonrails.org/u/Colin_Law1)\
**Post date:** [November 26, 2010, 9:10pm UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/5 "2010-11-26T21:10:32Z")

</div>

Is there a t\_login column in the UserSession table? Are you sure? Did you remember to run the migration to add it? If the answer is yes then please post schema.rb and user\_session.rb If that is large then use pastie.org

Colin

---

<div class="post-metadata">

**Author:** ![Konstantinos\_Loupos](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Konstantinos\_Loupos](https://discuss.rubyonrails.org/u/Konstantinos_Loupos)\
**Post date:** [November 26, 2010, 9:13pm UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/6 "2010-11-26T21:13:24Z")

</div>

Hi, My project does not have an authlogic.rb file to write the require "authlogic" line..... What i have done is i have installed authlogic in the gemfile using gem 'authlogic', :git =\> 'git://github.com/odorcicd/ authlogic.git', :branch =\> 'rails3'. Then i run the command bundle install and i didn't got any errors.

I have created from scratch a new application and now i get the following errors: NoMethodError in User\_sessions#new

Showing G:/.../AuthlogicTest/app/views/user\_sessions/new.html.erb where line #6 raised:

Model UserSession does not respond to t\_login Extracted source (around line #6):

3: \<%= form\_for @user\_session, :url =\> {:action =\> "create"} do |f|%\> 4: \<%= f.error\_messages%\> 5: \<%= f.label :t\_login%\> 6: \<%= f.text\_field :t\_login%\> 7: \<%= f.label :t\_password%\> 8: \<%= f.password\_field :t\_password%\> 9: \<%div%\>

When i comment out the text and password field i see the form but with no fields. I havent found a sollution yet. I googled the problem but nothing. Any other idea??

Thanks again!

---

<div class="post-metadata">

**Author:** ![Konstantinos\_Loupos](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Konstantinos\_Loupos](https://discuss.rubyonrails.org/u/Konstantinos_Loupos)\
**Post date:** [November 26, 2010, 9:20pm UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/7 "2010-11-26T21:20:55Z")

</div>

Hi colin, i dont see any UserSession table...

---

<div class="post-metadata">

**Author:** ![Colin\_Law1](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@Colin\_Law1](https://discuss.rubyonrails.org/u/Colin_Law1)\
**Post date:** [November 27, 2010, 8:51am UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/8 "2010-11-27T08:51:53Z")

</div>

That's ok (I had forgotten how authlogic works). Lets try again then 🙂Why have you got t\_login and t\_password in your view? Should it not just be :login and :password?

Colin

---

<div class="post-metadata">

**Author:** ![Konstantinos\_Loupos](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Konstantinos\_Loupos](https://discuss.rubyonrails.org/u/Konstantinos_Loupos)\
**Post date:** [November 27, 2010, 12:21pm UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/9 "2010-11-27T12:21:04Z")

</div>

Hi colin, i have used these names because i have already created a php application using these names and i want to create the same application in rails. Its for a project in my university. I dont want to have different field names .. Do you think the problem is the names??? I dont think so...

Kostas

---

<div class="post-metadata">

**Author:** ![Colin\_Law1](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@Colin\_Law1](https://discuss.rubyonrails.org/u/Colin_Law1)\
**Post date:** [November 27, 2010, 12:36pm UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/10 "2010-11-27T12:36:44Z")

</div>

Please don't top post, it makes it difficult to follow the thread. Insert your reply into the previous post. Thanks

> Hi colin, i have used these names because i have already created a php application using these names and i want to create the same application in rails. Its for a project in my university. I dont want to have different field names .. Do you think the problem is the names??? I dont think so...

Well the error message is NoMethodError, Model UserSession does not respond to t\_login which is saying the UserSession does not have a method t\_login, which suggests to me that the name is the problem. Have you done something somewhere else in your code to tell Authlogic to expect the different names?

It is easy enough to see if this is the problem here, just change those few lines of code and see if that error goes away.

Colin

---

<div class="post-metadata">

**Author:** ![Konstantinos\_Loupos](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Konstantinos\_Loupos](https://discuss.rubyonrails.org/u/Konstantinos_Loupos)\
**Post date:** [November 30, 2010, 7:58am UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/11 "2010-11-30T07:58:47Z")

</div>

Hi colin,

as i have seen, authlogic does require default names like login, password etc. I was using t\_login and t\_password as i result getting these errors.

I re-created my table with the new fields and everything works fine!!!

Home that helps someone else getting the same errors!!!

Thank you for your help!

Kostas Κωνσταντίνος Λούπος [louposk@gmail.com](mailto:louposk@gmail.com)

---

<div class="post-metadata">

**Author:** ![Philip\_Hallstrom](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@Philip\_Hallstrom](https://discuss.rubyonrails.org/u/Philip_Hallstrom)\
**Post date:** [November 30, 2010, 5:17pm UTC](https://discuss.rubyonrails.org/t/strange-error-while-using-authlogic/55689/12 "2010-11-30T17:17:27Z")

</div>

> Hi colin, as i have seen, authlogic does require default names like login, password etc. I was using t\_login and t\_password as i result getting these errors.

> I re-created my table with the new fields and everything works fine!!!

You can also tell authlogic what fields to use if you don’t want to rename it… either way…

-philip
