# Application error - SQL\_AUTO\_IS\_NULL

**URL:** <https://www.ruby-forum.com/t/application-error-sql-auto-is-null/126759>\
**Category:** Rails\
**Created:** [January 21, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/application-error-sql-auto-is-null/126759 "2008-01-21T23:55:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sd.codewarrior](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d26b3c/32.png) [@sd.codewarrior](https://www.ruby-forum.com/u/sd.codewarrior)\
**Post date:** [January 21, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/application-error-sql-auto-is-null/126759/1 "2008-01-21T23:55:27Z")

</div>

I have a simple controller (browse) that uses a “books” action to  
display a list of books (stored in a mysql db) and a “book\_details”  
action to display the details of a particular book (according to the  
book’s mysql id). The book\_details action is accessed via a link from  
the books action via the following snippet:

\<a href=\<%= “/browse/book\_details/#{\_bookID}” %\> class=“text11”  
style=“text-decoration:none”\>  
\<%= \_title %\>

where \_title is properly set to the book’s title and \_bookID is the  
mysql id of the book. I’ve verified that \_title and \_bookID are set  
properly. Equivalently, I’ve also used the following snippet instead  
of the above:

\<%= link\_to(\_title,  
{ :controller =\> “browse”,  
:action =\> “book\_details”,  
:id =\> \_bookID  
}) %\>

In both of the above cases, I’m using the default route: map.connect  
‘:controller/:action/:id’  
In my test environment (Windows XP, Instant Rails, Aptana IDE)  
everything works just fine. When I try to run this in production mode  
on the ISP’s site ([asmallorange.com](http://asmallorange.com) - CentOS) the books action works  
just fine but the book\_details action results in the extremely  
descriptive 😑 error message displayed as a webpage:

Application error  
Rails application failed to start properly

For the life of me, I don’t see what I’m doing wrong. On the ISP site,  
I set the log level to debug and compared the log files from both the  
test (Windows XP) and production (CentOS) environments. The only  
difference I could find is that in the CentOS production log, I see a  
SQL\_AUTO\_IS\_NULL message in the log file. I can’t figure out what this  
means and am not sure how relevant it is. Any suggestions are  
appreciated. Should I do something special with the routes?

Below are the two log files.

# ==================== test environment log file that works (Windows XP)

Processing BrowseController#book\_details (for 127.0.0.1 at 2008-01-21  
14:20:22)  
[GET]  
Session ID: e49a3adf336e845be40dc8573f2b32c9  
Parameters: {“action”=\>“book\_details”, “id”=\>“1”,  
“controller”=\>“browse”}  
e$B"+e(B[4;35;1mBook Columns (0.000000)e$B"+e(B[0m e$B"+e(B[0mSHOW  
FIELDS FROM  
bookse$B"+e(B[0m  
e$B"+e(B[4;36;1mBook Load (0.000000)e$B"+e(B[0m e$B"+e(B[0;1mSELECT

- FROM books WHERE  
(books.`id ` = 1) e$B"+e(B[0m  
Rendering within layouts/browse  
Rendering browse/book\_details  
Completed in 0.01600 (62 reqs/sec) | Rendering: 0.00000 (0%) | DB:  
0.00000 (0%)  
| 200 OK [[http://localhost/browse/book\_details/1](http://localhost/browse/book_details/1)]

# ==================== production environment log file that doesn’t work (CentOS)

# Logfile created on Mon Jan 21 14:29:06 -0500 2008 by /

Processing BrowseController#book\_details (for 69.143.120.176 at  
2008-01-21 14:29  
:06) [GET]  
Session ID: ded95bf9e5a23822f854e9ba58d69d6e  
Parameters: {“action”=\>“book\_details”, “id”=\>“1”,  
“controller”=\>“browse”}  
^[[4;36;1mSQL (0.000086)^[[0m ^[[0;1mSET SQL\_AUTO\_IS\_NULL=0^[[0m  
^[[4;35;1mBook Columns (0.001176)^[[0m ^[[0mSHOW FIELDS FROM  
books^[[0m  
^[[4;36;1mBook Load (0.000065)^[[0m ^[[0;1mSELECT \* FROM books  
WHERE (books.  
`id` = 1) ^[[0m  
Rendering within layouts/browse  
Rendering browse/book\_details  
Completed in 0.06461 (15 reqs/sec) | Rendering: 0.01440 (22%) | DB:  
0.00133 (2%)  
| 200 OK [[http://www.epps-alford.com/browse/book\_details/1](http://www.epps-alford.com/browse/book_details/1)]

---

<div class="post-metadata">

**Author:** ![sd.codewarrior](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d26b3c/32.png) [@sd.codewarrior](https://www.ruby-forum.com/u/sd.codewarrior)\
**Post date:** [January 23, 2008, 12:10am UTC](https://www.ruby-forum.com/t/application-error-sql-auto-is-null/126759/2 "2008-01-23T00:10:52Z")

</div>

On 1/21/08, sd.codewarrior [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have a simple controller (browse) that uses a “books” action to  
> display a list of books (stored in a mysql db) and a “book\_details”

Do your books have more than one set of details, per book?

> mysql id of the book. I’ve verified that \_title and \_bookID are set  
> properly. Equivalently, I’ve also used the following snippet instead  
> of the above:
> 
> \<%= link\_to(\_title,  
> { :controller =\> “browse”,  
> :action =\> “book\_details”,  
> :id =\> \_bookID  
> }) %\>

Why are you using all the underscore-prefixed \_vars ? What purpose do  
they serve?

When you get an ActiveRecord book object from the database does it not  
contain the book id? Why not reference it as is? @book.id or  
whatever.

> In both of the above cases, I’m using the default route: map.connect  
> ‘:controller/:action/:id’  
> In my test environment (Windows XP, Instant Rails, Aptana IDE)  
> everything works just fine. When I try to run this in production mode  
> on the ISP’s site ([asmallorange.com](http://asmallorange.com) - CentOS) the books action works  
> just fine but the book\_details action results in the extremely  
> descriptive 😑 error message displayed as a webpage:
> 
> Application error  
> Rails application failed to start properly

In production it’s wise to not display visible errors on the screen,  
which is exactly what Rails does by default.

> For the life of me, I don’t see what I’m doing wrong. On the ISP site,  
> I set the log level to debug and compared the log files from both the  
> test (Windows XP) and production (CentOS) environments. The only  
> difference I could find is that in the CentOS production log, I see a  
> SQL\_AUTO\_IS\_NULL message in the log file. I can’t figure out what this  
> means and am not sure how relevant it is.

Google returned this as the first result when I searched:

[http://dev.mysql.com/doc/refman/5.0/en/set-option.html](http://dev.mysql.com/doc/refman/5.0/en/set-option.html)

SQL\_AUTO\_IS\_NULL = {0 | 1}

If set to 1 (the default), you can find the last inserted row for a  
table that contains an AUTO\_INCREMENT column by using the following  
construct:

WHERE auto\_increment\_column IS NULL

> Any suggestions are  
> appreciated. Should I do something special with the routes?

If you app requires it, yes. I see nothing in your post to warrant  
any changes to the default however.

> “controller”=\>“browse”}
> 
> Session ID: ded95bf9e5a23822f854e9ba58d69d6e  
> Completed in 0.06461 (15 reqs/sec) | Rendering: 0.01440 (22%) | DB:  
> 0.00133 (2%)  
> | 200 OK [[http://www.epps-alford.com/browse/book\_details/1](http://www.epps-alford.com/browse/book_details/1)]

I think you will find your problem somewhere in your \_var  
(re)assignments.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![sd.codewarrior](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d26b3c/32.png) [@sd.codewarrior](https://www.ruby-forum.com/u/sd.codewarrior)\
**Post date:** [January 23, 2008, 3:36pm UTC](https://www.ruby-forum.com/t/application-error-sql-auto-is-null/126759/3 "2008-01-23T15:36:05Z")

</div>

Greg,

Thanks for your feedback.

> I think you will find your problem somewhere in your \_var (re)assignments.

My style of variable name derives from coding in other languages (Java/  
C++). I didn’t think that was related but switched the variables  
around just in case per your suggestion. Unfortunately that didn’t  
help.

It turns out that the problem was unrelated to variable names or the  
SQL\_AUTO\_IS\_NULL setting. The problem was due to a puts statement in  
my controller. The following action was defined in my controller:

def book\_details  
puts “ID equals #{params[:id]}”  
@book = Book.find(params[:id])  
@pageTitle = “Epps-Alford Bookstore”  
end

This caused the mysterious error. Things worked fine on my development  
machine (Windows XP, InstantRails) but crapped out in the production  
environment (CentOS). By removing the puts method, the action started  
working in the production environment on Linux/CentOS.

Thanks!!!
