Active Record

I want to build a one page finance calculator in Rails.
The form has several fields on it. When I press the calculate button
it will return to the same page with the answer. If there is an error
it will also return to the same page with the appropriate error
messages.

I want it to be able to

  1. Carry over all the values on the form fields
  2. Use the rails validation methods

How can I acheive this without Active Record being tied to a particular
database table?

possibly a global hash?

is this safe?

Hi there,

On 8/2/06, Guest [email protected] wrote:

I want it to be able to

  1. Carry over all the values on the form fields
  2. Use the rails validation methods

How can I acheive this without Active Record being tied to a particular
database table?

There are some examples for ActiveRecord validation without using a
database table. Mostly related to contact forms, where the data is
emailed not stored.

The one I use is like:

class Contact < ActiveRecord::Base
def self.columns() @columns ||= []; end
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to
_s, default, sql_type.to_s, null)
end
column :name, :string
column :city, :string
column :country, :string
column :phone, :string

validates_presence_of :name, :city, :country, :phone
end

Best Regards
Eaden McKee

If you don’t need to store the data, why use ActiveRecord? It seems
like an overkill for a one page calculator.

Zack