Dynamic Forms and Values

Hi people,

I’m relativly new to the rails business so i have a rather noobish
question:

I have to create an app that has dynamic forms. That means, that I habe
about 10 Forms that all have a subset of attributes they share and some
that are unique to the type of form. Example:

Shared fields:

  • created_at
  • created_by
  • customer_id
  • current_state

Fields needed in Form1

  • healthinsurance_name
  • healthinsurance_street

Fields needed in Form2

  • bank_name
  • account_number

So Form1 and Form2 share the fields created_at, etc.

Then I need to store values and define restrictions to the fields like
unique or things like if bank_name is set, account_number must be set
too.

I’m a little bit lost, how to begin with this stuff. I have been looking
at STI but I’m not sure whether ist’s what I need or not.

An optional feature would be to be able to define these dynamic forms
inside of the application.

So…any ideas?

thank you all!

Greetings,

Robotex

bump

Is this so weird that no one has any clue? or am is the question too
stupid…?!

no one?

So Form1 and Form2 share the fields created_at, etc.

created_at is one of ActiveRecord’s special fields and will be
populated automatically by Rails if it exists in your database
table. Similar fields are created_on, updated_at and updated_on.
The _at columns should be timestamps and the _on ones should be dates.

http://api.rubyonrails.org/classes/ActiveRecord/Timestamp.html

Then I need to store values and define restrictions to the fields like
unique or things like if bank_name is set, account_number must be set
too.

The built-in validations make these really easy. Have a look at:

http://api.rubyonrails.org/classes/ActiveRecord/Validations/
ClassMethods.html

Hope that helps,
Andy S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs