New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with ActiveRecord and Sequel ORM #1653

Closed
ghost opened this Issue Apr 9, 2014 · 4 comments

Comments

Projects
None yet
3 participants
@ghost

ghost commented Apr 9, 2014

Hello,
I've been trying out Padrino with a plan to convert couple of restful web services written in plain Sinatra to take advantage of features offered in Padrino. To learn about Padrino, I started with a the sample blog tutorial and ran into a couple of issues with ORMs:

First Issue.

Using AR as the ORM, setting up Admin panel throws an error after the sample username and password is entered. Here is the initial command I entered:

 sample_blog$ bundle exec rake ar:create ar:migrate seed

Output:

bundle exec rake ar:create ar:migrate seed
  DEBUG -  ActiveRecord::SchemaMigration Load (0.1ms)  SELECT "schema_migrations".* FROM "schema_migrations"
  DEBUG -  ActiveRecord::SchemaMigration Load (0.2ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Which email do you want use for logging into admin? test@foo.com
Tell me the password to use: bar123

  DEBUG -   (0.2ms)  begin transaction
  DEBUG -  Account Exists (0.2ms)  SELECT  1 AS one FROM "accounts"  WHERE LOWER("accounts"."email") = LOWER('test@foo.com') LIMIT 1
  DEBUG -  SQL (3.3ms)  INSERT INTO "accounts" ("created_at", "crypted_password", "email", "name", "role", "surname", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?)  [["created_at", "2014-04-09 14:21:43.438626"], ["crypted_password", "$2a$10$ct68qhwdjk5866PsRe1Dy.Mv6zupFQnYuE29VO/0mV4NTsP0Io416"], ["email", "test@foo.com"], ["name", "Foo"], ["role", "admin"], ["surname", "Bar"], ["updated_at", "2014-04-09 14:21:43.438626"]]
  DEBUG -   (12.3ms)  commit transaction
  DEBUG -  Account Exists (0.1ms)  SELECT  1 AS one FROM "accounts"  WHERE (LOWER("accounts"."email") = LOWER('test@foo.com') AND "accounts"."id" != 1) LIMIT 1
=================================================================
Account has been successfully created, now you can login with:
=================================================================
   email: test@foo.com
   password: bar123
=================================================================

When I login to the admin panel using the password, I see the following error:
application error
ArgumentError at /admin/sessions/create
invalid value for Integer(): "{:conditions=>["lower(email) = lower(?)""
file: database_statements.rb
location: Integer
line: 332

Here is my ruby and Gemlock file for version of components I'm using:

ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
gem -v
2.1.11
cat Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    activemodel (4.1.0)
      activesupport (= 4.1.0)
      builder (~> 3.1)
    activerecord (4.1.0)
      activemodel (= 4.1.0)
      activesupport (= 4.1.0)
      arel (~> 5.0.0)
    activesupport (4.1.0)
      i18n (~> 0.6, >= 0.6.9)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.1)
      tzinfo (~> 1.1)
    arel (5.0.0)
    bcrypt (3.1.7)
    builder (3.2.2)
    haml (4.0.5)
      tilt
    http_router (0.11.1)
      rack (>= 1.0.0)
      url_mount (~> 0.2.1)
    i18n (0.6.9)
    json (1.8.1)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.25.1)
    minitest (5.3.2)
    moneta (0.7.20)
    padrino (0.12.1)
      padrino-admin (= 0.12.1)
      padrino-cache (= 0.12.1)
      padrino-core (= 0.12.1)
      padrino-gen (= 0.12.1)
      padrino-helpers (= 0.12.1)
      padrino-mailer (= 0.12.1)
      padrino-support (= 0.12.1)
    padrino-admin (0.12.1)
      padrino-core (= 0.12.1)
      padrino-helpers (= 0.12.1)
    padrino-cache (0.12.1)
      moneta (~> 0.7.0)
      padrino-core (= 0.12.1)
      padrino-helpers (= 0.12.1)
    padrino-core (0.12.1)
      activesupport (>= 3.1)
      http_router (~> 0.11.0)
      padrino-support (= 0.12.1)
      rack-protection (>= 1.5.0)
      sinatra (~> 1.4.2)
      thor (~> 0.18.0)
    padrino-gen (0.12.1)
      bundler (~> 1.0)
      padrino-core (= 0.12.1)
    padrino-helpers (0.12.1)
      i18n (~> 0.6, >= 0.6.7)
      padrino-support (= 0.12.1)
      tilt (~> 1.4.1)
    padrino-mailer (0.12.1)
      mail (~> 2.5.3)
      padrino-core (= 0.12.1)
    padrino-support (0.12.1)
      activesupport (>= 3.1)
    polyglot (0.3.4)
    rack (1.5.2)
    rack-protection (1.5.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rake (10.2.2)
    sass (3.3.4)
    shoulda (3.5.0)
      shoulda-context (~> 1.0, >= 1.0.1)
      shoulda-matchers (>= 1.4.1, < 3.0)
    shoulda-context (1.2.1)
    shoulda-matchers (2.5.0)
      activesupport (>= 3.0.0)
    sinatra (1.4.5)
      rack (~> 1.4)
      rack-protection (~> 1.4)
      tilt (~> 1.3, >= 1.3.4)
    sqlite3 (1.3.9)
    thor (0.18.1)
    thread_safe (0.3.3)
    tilt (1.4.1)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (1.1.0)
      thread_safe (~> 0.1)
    url_mount (0.2.1)
      rack

PLATFORMS
  ruby

DEPENDENCIES
  activerecord (>= 3.1)
  bcrypt
  haml
  padrino (= 0.12.1)
  rack-test
  rake
  sass
  shoulda
  sqlite3

Second Issue

I switched to sequel to attempt to reproduce this issue with another ORM - I had the suspicion that AR is causing this based on the backtrace, so went with Sequel and SQLite to test it. I used the bundle exec rake sq:create sq:migrate seed which reports that Sequel create is not supported. How to work around that?

My applications use MySQL for one service and Mongo for another and I need to try out both those ORM and sample applications on Padrino before rewriting. Any help on these issues is greatly appreciated.

Thanks,
Ajith

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Apr 9, 2014

Member

Fixed both issues. Thank you for your report.

Member

ujifgc commented Apr 9, 2014

Fixed both issues. Thank you for your report.

@ujifgc ujifgc closed this Apr 9, 2014

@mreq

This comment has been minimized.

Show comment
Hide comment
@mreq

mreq May 7, 2014

Still happens in the stable branch. Shouldn't a 0.12.2 be pushed out?

mreq commented May 7, 2014

Still happens in the stable branch. Shouldn't a 0.12.2 be pushed out?

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena May 7, 2014

Member

Happy to push out a 0.12.2 this weekend.

Member

nesquena commented May 7, 2014

Happy to push out a 0.12.2 this weekend.

@mreq

This comment has been minimized.

Show comment
Hide comment
@mreq

mreq May 7, 2014

cool 👍

mreq commented May 7, 2014

cool 👍

@ujifgc ujifgc added the bug label Aug 6, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment