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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:07:07+00:00 2026-05-19T09:07:07+00:00

I experienced a horrible problem today as a result of differences between Rail’s production

  • 0

I experienced a horrible problem today as a result of differences between Rail’s production and development environments. Consider the code:

"select * from subscription_plans where affiliate_id is null or affiliate_id = #{@subscription_plan.affiliate.id rescue 0};"

There will never be any affiliates with an id of 0, so if @subscription_plan.affiliate is nill I expected the query to return only subscription plans without an affiliate. Works great in development environment because nil.id throws an error (provided it does give some message about it should mistakenly be 4). Problem is, I pushed that code live to my production server and subscription plans with an affiliate_id of 4 started showing up all over. In production, nil.id doesn’t throw an error, but rather simply returns 4. Geez, thanks rails.

All that to ask, what other things should I be aware of as a Rails developer? In particular, are there other differences between environments that could potentially cause problems?

  • 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-19T09:07:08+00:00Added an answer on May 19, 2026 at 9:07 am

    Everything that’s different between production and development is configurable. If you want whiny nils in production, add this to your production.rb file:

    # Log error messages when you accidentally call methods on nil.
    config.whiny_nils = true
    

    Just look at your config/environments/production.rb and config/environments/development.rb files and read the comments and documentation on the methods/properties being used. Off the top of my head, here are some differences:

    1. Code is not reloaded in production, so if you have any constants that are set to Time.now or 1.day.ago or whatever in development that work as expected, they won’t work in production.
    2. debug level log messages are ignored in production.
    3. caching is enabled only in production
    4. verbose error messages are only available in development (though they are logged to the rails log)

    There are more, probably, but if you just check out the config files you should get a good idea of what the differences are.

    Also, a brief code critique:

    1. The rescue foo pattern is generally a bad idea. Legitimate errors that may have been raised will be ignored.
    2. Use ActiveRecord SQL interpolation to add dynamic values to a SQL string, don’t use #{}.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our team is experienced in web development (tomcat/Oracle) but not with AJAX on our
I am an experienced .NET applications developer. All of my development experience has been
I have experienced a strange problem in windows vista and above. When I use
I am experienced with web development, but not with PHP. My challenge now is
I consider myself an experienced programmer and understand the basic concept of dependency injection.
Experienced with Rails / ActiveRecord 2.1.1 You create a first version with (for example)
I'm an experienced client application developer (C++/C#), but need to come up to speed
I'm a pretty experienced Java programmer that's been doing quite a bit of Win32
I've experienced rather strange behavior of JSTL forEach tag. I have some bean called
I'm a pretty experienced Grails developer, but most of my experience has been with

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.