Forum: Rails deployment This code doesn't work in production

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
68d1b077ca013419a8627dbc0bf2372d?d=identicon&s=25 Robert Lorimor (bobbyl)
on 2007-07-29 15:48
The code below works in my development server on my home computer.
However, the code breaks with a 'Internet minimum invalid' validation
error when deploy to production server.

What could the problem be? HOw might I track down what causing this?

the code:
#In my shop controller
def update
  @mins =
  @shop.update_attributes( params[ :shop ] )
  @line_of_sale =  @shop.line_of_sales.find( :first, :conditions =>
'type = "InternetRate"' ) ||
    @line_of_sale =
  @line_of_sale.update_attributes( params[ :line_of_sale ] ) = 'Internet Rate' #  default if new or old, there
is only one per shop
  @shop.all_internet_minimums.each { |min| min.destroy }
  if params[ :internet_minimums ]
    params[ :internet_minimums ].each_value do |min | unless min.values.all?(
&:blank? )
  Shop.transaction do! = @shop!
    flash[ :notice ] = 'Shop was successfully updated.'
    redirect_to :action => :index
rescue ActiveRecord::RecordInvalid => e
  render :action => :setup

class InternetMinimum < ActiveRecord::Base

  belongs_to :shop

  validates_presence_of :minutes, :min_charge, :message => "must be
  validates_uniqueness_of :minutes, :message => "must be unique", :scope
=> 'shop_id'
  validates_numericality_of :minutes, :only_integer => true, :message =>
"number only, no other characters allowed"
  validates_numericality_of :min_charge, :message => 'must be a number
(decimal is OK)'
  validates_length_of :minutes, :maximum => 4


#Inside my view
  <ol id="min_sets">
  <% @shop.internet_minimums.each_with_index do |mins, index| %>
    <%= render :partial => 'set_field', :locals => { :mins => mins,
:index => index } %>
  <% end %>
  <% if @shop.internet_minimums.size == 0 %>
    <%= render :partial => 'set_field', :locals => { :mins => @mins,
:index => 0 } %>
  <% end %>
  <%= render :partial => 'add_set_link', :locals => { :index =>
@shop.internet_minimums.size + 1 } %>

<% fields_for "internet_minimums[#{index}]", mins do |ff| %>
  <li id="min_set_<%= index %>">Minutes: <%= ff.text_field :minutes,
:size => 2, :maxlength => 4 %>
  Minimum Charge: <%= ff.text_field :min_charge, :size => 2 %>
   <small><%= link_to_remote 'remove', :url => { :action =>
'remove_set', :index => index } %></small></li>
<% end %>

<p id="add_set_link">
  <%= link_to_remote 'add minimum set',
      :url => { :action => 'add_set', :index => index } %>
A82ba1167f4d4a8d1de63820e576a87f?d=identicon&s=25 Robby Russell (Guest)
on 2007-07-30 00:03
(Received via mailing list)
Are you able to reproduce it with tests or specs? Are the same
versions of Ruby and Rails installed?

On a side note, you might consider reading up on skinny controllers,
fat models.

Here are a few links..

Good luck!


On Jul 29, 2007, at 6:48 AM, Robert Lorimor wrote:

> def update
>     params[ :internet_minimums ].each_value do |min |
>   end
>   validates_length_of :minutes, :maximum => 4
>     <%= render :partial => 'set_field', :locals => { :mins => @mins,
> :size => 2, :maxlength => 4 %>
> ==========
> --
> Posted via
> >

Robby Russell
Founder and Executive Director

Design, Development, and Hosting with Ruby on Rails

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4068 [fax]
68d1b077ca013419a8627dbc0bf2372d?d=identicon&s=25 Robert Lorimor (bobbyl)
on 2007-07-30 07:48
Robby, thanks for replying.

My development setup is:

Ubuntu 7.04 Feisty Fawn
ruby 1.8.5
rails 1.2.3
mongrel 1.0.1 #I use mongrel for my development server
MySQL 5+

On my production server:

Ubuntu 6.10 LTS Dapper
ruby 1.8.6 #Initial this was ruby 1.8.4, see notes below
rails 1.2.3
mongrel 1.0.1
apache 2.2
MySQL 5+

The first thing I tried to fix this was rebuild my VPS slice to have the
latest ruby 1.8.6 instead of the default ruby 1.8.4. Ubuntu Server
Dapper install ruby 1.8.4 by default. Feisty Fawn install 1.8.5 by

There server was built with Mike Bailey's Deprec for Capistrano. Inside
the recipe, I found these apt-get packages:

build-essential ntp-server mysql-server wget ruby irb ri rdoc
ruby1.8-dev libopenssl-ruby libmysql-ruby zlib1g-dev zlib1g openssl
libssl-dev subversion

The next thing I am going to try to is write some tests to see if it
breaks locally.

If I had to guess, I would say the ".build" method is not working on
production server. I can't find any documentation on this method.

Note that the server use apache to server the pages. Could that be the
problem in some way?
4e25326d3e557403cd65c4194144d90e?d=identicon&s=25 Eli Miller (jqr)
on 2007-08-17 13:52
Robert Lorimor wrote:
> The next thing I am going to try to is write some tests to see if it
> breaks locally.

Tests will almost assuredly help you find the root of this problem
faster than we can. Probably the easiest way would be to run
error_messages_for('mins') in your view.

> If I had to guess, I would say the ".build" method is not working on
> production server. I can't find any documentation on this method.

This seems unlikely, .build has been around for some time. For some very
breif documentation, search for build on this page:
68d1b077ca013419a8627dbc0bf2372d?d=identicon&s=25 Robert Lorimor (bobbyl)
on 2007-08-18 13:41
I solved this problem, though I am not 100% sure how I fixed.

In the process of writing test, I decided to remove an feedtool gem I
was also having problems with. The code now works just as it does on my
development server.

Thanks to everyone who tried to help.
This topic is locked and can not be replied to.