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?
Jason Cartwright 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 Farmer <farmerje@uchicago.edu> University of Chicago - NSIT Web Services AIM: farmerje Jabber: farmerje@im.uchicago.edu Phone: (773)363-1058
Jesse Farmer <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?
Jason Cartwright wrote:> Jesse Farmer <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 -- Posted via http://www.ruby-forum.com/.
On 1/13/06, Kevin Olbrich <kevin.olbrich@duke.edu> wrote:> > 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > 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? -- Larry http://www.approachingnormal.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060114/2186f9f9/attachment-0001.html
Larry Wright <larrywright@...> writes:> 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?-- > Larryhttp://www.approachingnormal.com > > > _______________________________________________ > 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.
jason cartwright wrote:> Larry Wright <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 -- Posted via http://www.ruby-forum.com/.
I too posted a similar problem. Has anyone found a solution or has any clues? tia, Roberto -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---