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? -- Posted via http://www.ruby-forum.com/.
possibly a global hash? is this safe? On 8/2/06, Guest <simon_domino@yahoo.com> wrote:> > 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? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060802/707036e9/attachment.html
Hi there, On 8/2/06, Guest <simon_domino@yahoo.com> 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 -- Webforce Ltd. | www.webforce.co.nz
If you don''t need to store the data, why use ActiveRecord? It seems like an overkill for a one page calculator. Zack On 8/1/06, Eaden McKee <eaden.mckee@gmail.com> wrote:> Hi there, > > On 8/2/06, Guest <simon_domino@yahoo.com> 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 > -- > Webforce Ltd. | www.webforce.co.nz > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >