Forum: Ruby on Rails user-defined columns

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jason C. (Guest)
on 2006-01-12 20:26
(Received via mailing list)
I am breaking ground on a new project and one of the issues I expect to
encouter
is the ability of users to define their own columns. For example, one of
the
features of this application will be the ability to store information
about
people's skills and then search for and schedule them based on this
information.
Since every organization's needs are different, it would be ideal to
allow each
organization to extend the basic schema dynamically.

Has anyone else dealt with this scenario in Rails? Are there advantages
to using
a particular database for this?
Jesse F. (Guest)
on 2006-01-12 20:38
(Received via mailing list)
Jason C. wrote:
> I am breaking ground on a new project and one of the issues I expect to encouter
> is the ability of users to define their own columns. For example, one of the
> features of this application will be the ability to store information about
> people's skills and then search for and schedule them based on this information.
> Since every organization's needs are different, it would be ideal to allow each
> organization to extend the basic schema dynamically.
>
> Has anyone else dealt with this scenario in Rails? Are there advantages to using
> a particular database for this?

Why not instead use a tagging system?  You can store arbitrary key/value
pairs in the database in a generic way, e.g., have a table called
"tags."  There are plenty of resources out there about how to do this,
just search Google for Rails+tagging.

--
Jesse F. <removed_email_address@domain.invalid>
University of Chicago - NSIT Web Services
AIM:    farmerje
Jabber: removed_email_address@domain.invalid
Phone:  (773)363-1058
Jason C. (Guest)
on 2006-01-13 18:10
(Received via mailing list)
Jesse F. <farmerje@...> writes:

> Why not instead use a tagging system?  You can store arbitrary key/value
> pairs in the database in a generic way, e.g., have a table called
> "tags."  There are plenty of resources out there about how to do this,
> just search Google for Rails+tagging.
>

Tagging is an interesting option that I hadn't considered. I don't have
the
requirements solidified yet, but it might be sufficient. However, simple
key/value pairing might not offer enough control. For instance, it might
be
necessary to indicate level of skill/proficiency, meaning that the
end-user
could define custom attributes with custom defined values. Is that
something
that tagging would provide?
Kevin O. (Guest)
on 2006-01-13 18:35
Jason C. wrote:
> Jesse F. <farmerje@...> writes:
>
>> Why not instead use a tagging system?  You can store arbitrary key/value
>> pairs in the database in a generic way, e.g., have a table called
>> "tags."  There are plenty of resources out there about how to do this,
>> just search Google for Rails+tagging.
>>
>
> Tagging is an interesting option that I hadn't considered. I don't have
> the
> requirements solidified yet, but it might be sufficient. However, simple
> key/value pairing might not offer enough control. For instance, it might
> be
> necessary to indicate level of skill/proficiency, meaning that the
> end-user
> could define custom attributes with custom defined values. Is that
> something
> that tagging would provide?

Polymorphic associations (from edgerails) might also work well for this.
However...

There is no reason that rails can't add/drop table columns through SQL
calls.  Since ActiveRecord is good at picking up things from the table
structure, it would probably work pretty well.  You would have to do
some introspection to know what columns had been added, but that is
pretty easy with RoR.

_Kevin
Larry W. (Guest)
on 2006-01-14 22:01
(Received via mailing list)
On 1/13/06, Kevin O. <removed_email_address@domain.invalid> wrote:
> _Kevin
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


I've got a similar need potentially, so I'm glad to see some discussion
around this topic. The only issue with adding the fields dynamically is
how
to handle multi-user systems. Take Basecamp for example, if they allowed
for
adding custom fields. Certainly there is only one database for everyone
using Basecamp, as doing otherwise would likely not be feasible. So how
do
you handle it for these situations?
jason cartwright (Guest)
on 2006-01-15 06:07
(Received via mailing list)
Larry W. <larrywright@...> writes:

> _______________________________________________
> Rails mailing list
> Rails@...
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


I share that concern as well. The application I am designing would also
be a
multi-user database. I guess it would be possible to create a new
instance of
the application for each customer, but surely that would become
unmanageable
with any level of success.

For sake of discussion, can anyone provide a sample of how creating
columns via
ActiveRecord might be implemented? I am fairly new to Rails, so I'm not
completely familiar with how you do introspection and such. In C# I
handle
Reflection with precision and ease, but these dynamic languages are
still a
mental stretch for me.
Jake J. (Guest)
on 2006-04-04 19:20
jason cartwright wrote:
> Larry W. <larrywright@...> writes:
>
>> _______________________________________________
>> Rails mailing list
>> Rails@...
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>
>
> I share that concern as well. The application I am designing would also
> be a
> multi-user database. I guess it would be possible to create a new
> instance of
> the application for each customer, but surely that would become
> unmanageable
> with any level of success.
>
> For sake of discussion, can anyone provide a sample of how creating
> columns via
> ActiveRecord might be implemented? I am fairly new to Rails, so I'm not
> completely familiar with how you do introspection and such. In C# I
> handle
> Reflection with precision and ease, but these dynamic languages are
> still a
> mental stretch for me.


I just found this thread after posting a similar topic.  Was any decent
solution found for the problem of user-defined columns?

Allowing the application to add/remove columns is not an option for me.
The database will be shared among many users.

Tagging as I understand it doesn't provide what I'm looking for either.
I'll need a key/value pair for rows in a database.  The keys will be
user-defined for the entire account and will only be mutable by the
administrator of that particular account.

   Jake
Roberto V. (Guest)
on 2006-10-17 11:53
I too posted a similar problem. Has anyone found a solution or has any
clues?


tia,

Roberto
This topic is locked and can not be replied to.