Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9171261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:08:19+00:00 2026-06-17T16:08:19+00:00

Answered. See the end of post. I am mainly a Java developer and fairly

  • 0

Answered. See the end of post.

I am mainly a Java developer and fairly new to Ruby on Rails. I have successfully gone through the tutorial at railstutorial.org. So I got this to work once. My problem has come up when I started going through the tutorial a second time but this time trying to replace the authentication with the Sorcery gem. My main reference for that was episode #283 on railscasts.org. Some of it was working but when I try to sign in, I get an error saying:

ActiveRecord::PreparedStatementInvalid in SessionsController#create

missing value for :email in [:email] = :login

This was a difficult thing to search for since it is quite specific but with very general words that appear in a lot of places. I think I am doing things the same way as in the original tutorial when I had it working. Below is my views/sessions/new.html.erb which is just about the same as the original tutorial.

<% provide(:title, "Sign in") %>
<h1>Sign in</h1>

<div class="row">
  <div class="span6 offset3">
    <%= form_for(:session, url: sessions_path) do |f| %>

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

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

      <%= f.check_box :remember_me %>
      <%= f.label :remember_me %>
  
      <%= f.submit "Sign in", class: "btn btn-large btn-primary" %>
    <% end %>

    <p>New user? <%= link_to "Sign up now!", signup_path %></p>
  </div>
</div>

And here is the create method in my sessions_controller.rb which is a little different from the tutorial because of sorcery, but I don’t know why params references are not working the same way as in the tutorial:

def create
  user = login(params[:session][:email], params[:session][:password])
  if user
    redirect_back_or_to root_url, :notice => "Logged in!"
  else
    flash.now[:error] = 'Invalid email/password combination' # Not quite right!
    render 'new'
  end
end

The rails cast just uses params[:email] but that was because he used form_tag instead of form_for and changed which param to use.

I’m really lost here. Not sure why it isn’t working the same as the tutorial. Any help would be greatly appreciated. Let me know if I should provide any additional information. Thanks.

EDIT:
Added the full error above. It must be some problem with sorcery’s login method or my database. The parameters are coming through fine. Here’s the full stack trace (back to my part of the code. It’s really too long beyond that.)

Stack trace:

activerecord (3.2.11) lib/active_record/sanitization.rb:141:in `block in replace_named_bind_variables’

activerecord (3.2.11) lib/active_record/sanitization.rb:135:in `gsub’

activerecord (3.2.11) lib/active_record/sanitization.rb:135:in `replace_named_bind_variables’

activerecord (3.2.11) lib/active_record/sanitization.rb:115:in `sanitize_sql_array’

activerecord (3.2.11) lib/active_record/sanitization.rb:28:in `sanitize_sql_for_conditions’

activerecord (3.2.11) lib/active_record/relation/query_methods.rb:324:in `build_where’

activerecord (3.2.11) lib/active_record/relation/query_methods.rb:136:in `where’

activerecord (3.2.11) lib/active_record/querying.rb:9:in `where’

sorcery (0.7.13) lib/sorcery/model/adapters/active_record.rb:32:in `find_by_credentials’

sorcery (0.7.13) lib/sorcery/model.rb:108:in `authenticate’

sorcery (0.7.13) lib/sorcery/controller.rb:33:in `login’

app/controllers/sessions_controller.rb:8:in `create’

I guess I’m too new to answer my own question right away. Fixed it myself:

In sorcery.rb, I had:

user.username_attribute_names = ‘[:email]’

Apparently, the quotes shouldn’t be there. I was confused by the comments in the file. After I made that change I needed to restart the server for the change to take effect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:08:20+00:00Added an answer on June 17, 2026 at 4:08 pm

    Fixed it myself:

    In sorcery.rb, I had:

    user.username_attribute_names = ‘[:email]’

    Apparently, the quotes shouldn’t be there. I was confused by the comments in the file. After I made that change I needed to restart the server for the change to take effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After having my last question answered , I have never see the preventDefault(); function
Edit: Answered my own question. See below. -_- I have a variable defined in
I'm fairly new to ruby. Recently, I wanted to extract a portion of a
I have had a look to see if this has been answered but to
Question Answered, see solution at end of question. More comments / answers still welcome.
I am brand new to Jquery and have run into something that if answered
I can see this topic has been brought up before but not answered successfully.
I have searched everywhere and can not see that this has been answered for
UPDATE (spoiler): This question is answered (see David Carlisle answere below) and it looks
I see a couple of previously answered questions about adding an item to an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.