Creating a "database" in rails
I have a rails 4 application where users define for example a tools
database and creates fields that store items like brand, year, etc. Then a
CRUD interface is presented before them, based on the fields they defined.
Right now I have a Database model that looks like this:
class Database < ActiveRecord::Base
has_many :fields
and a Field Model that looks like this:
class Field < ActiveRecord::Base
belongs_to :database
Basically, right now on the Add Fields page (which is after you have a
created a database and defined the fields), I'm creating a unique id and
storing that with all the fields on that page, which I then use to group
fields into a "row" (using a rails groupby statement).
I have two questions: 1. Is the most efficient way to implement a
"database"? 2. I can't figure out how to best link the field names you
define when you create the database with the fields in the CRUD interface.
So for example, If I create a name field when I'm initially defining all
of the fields, how can I have it associated with fields in the CRUD
interface?
Thanks for all help! If I need to clarify more, please tell!
No comments:
Post a Comment