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 6850471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:07:43+00:00 2026-05-27T01:07:43+00:00

Hello! It is happening a very weird thing when I save a model in

  • 0

Hello!
It is happening a very weird thing when I save a model in rails 3.1

Same project in development / production

There is a simple model City with 2 fields (name / state).

development console

city = City.new(:name => "Sao Paulo", :uf => "SP")
city.save (true, no validations errors and record is created in database)

if I call “city.id”, I get real value of ID saved in database, e.g. 123.
It is working fine in development.

production console

city = City.new(:name => "Sao Paulo", :uf => "SP")
city.save (true, no validations errors and record is created in database)

if I call “city.id”, I get value equal 0 (different from value created automatically in database)

City.last (check if record is created in database...)
<City id: 22257, name: "Sao Paulo", uf: "SP", created_at: "2011-11-23 00:52:53", updated_at: "2011-11-23 00:52:53">

The record is created in database but not returns ID after call save/create. Did anyone see this before? This is the first time I see this behavior in production. It happens to every model in project. I used model City because it is the simplest one.
I am running rails 3.1.

Thanks for help!

  • 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-05-27T01:07:44+00:00Added an answer on May 27, 2026 at 1:07 am

    I found the solution!!! I was using ‘mysql’ gem insted ‘mysql2’. When I changed to mysql2 (in Gemfile and database.yml adapter), everything worked fine. It is probably an incompatibility issue betwen gem ‘mysql’ and rails 3.1. Thanks you all for help!

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

Sidebar

Related Questions

Something's very weird is happening to my rewriting rules when moved to shared hosting
Hello all I have a simple Spring application which will not end as there
Something really weird is happening to my Rails app. For some strange reason, jQuery
Hello there and Merry Christmas !!! I am new to WPF and I am
I'm developping a very simple app on my Ubuntu using QtCreator. It's a console
Hello Again my fellow programmers out there, I'm designing and programming from scratch a
Hello there I am working on an assignment in C where I need to
I am using iOS SDK 4.2 and followed this tutorial: http://mobileorchard.com/hello-there-a-corelocation-tutorial/ , and got
Hello good people of stackoverflow, I am having a weird problem while following Adam
This maybe a very noobish question but I am trying to implement a simple

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.