Displaying 1 result from an estimated 1 matches for "customer_base".
2006 Sep 30
6
generating unique tracking numbers
...blematic having assigned
ids if tables ever need to be reogranized.
I think it would be preferrable to use a sequence, but haven''t found a
way of doing this with MySQL, so I just increment the max value of the
id column. Here''s how I generate a customer number:
application.rb:
CUSTOMER_BASE = "10000"
def next_id(table_name, column)
ActiveRecord::Base.connection.select_value("select max(#{column})+1
from #{table_name}")
end
customer_controller.rb:
def create
@customer.number = CUSTOMER_BASE.to_i + next_id(''customers'',
''id...