I''ve a requirement to put some user-managed attributes on a model. Essentially, I want Entity-Attribute-Value functionality - the administrator has the ability to create "fields" on the model, and to specify their type (datetime, string, boolean, decimal, etc). Then in the regular views, those fields are show in addition to all the normal fields from the model''s table. This could work with a :has_many relationship; with the parent model having an overloaded "method missing" call to look for any members of the associated attributes that match called-for methods. I could roll-my-own, but thought I''d look at any existing EAV options first; but have found thin pickings! There''s a fork of "acts_as_eav_model" on Github [1] which allows for flexible attributes on models; and to my mind, "all" I need to do to have this do what I want is have some form of admin system to populate the :meta_columns hash with the user-declared options. But can anyone suggest any other options that might be worth considering? [1] http://github.com/dwg/acts_as_eav_model/ -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 3 June 2010 15:06, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve a requirement to put some user-managed attributes on a model. > > Essentially, I want Entity-Attribute-Value functionality - the > administrator has the ability to create "fields" on the model, and to > specify their type (datetime, string, boolean, decimal, etc). Then in > the regular views, those fields are show in addition to all the normal > fields from the model''s table. This could work with a :has_many > relationship; with the parent model having an overloaded "method > missing" call to look for any members of the associated attributes > that match called-for methods. > > I could roll-my-own, but thought I''d look at any existing EAV options > first; but have found thin pickings! > There''s a fork of "acts_as_eav_model" on Github [1] which allows for > flexible attributes on models; and to my mind, "all" I need to do to > have this do what I want is have some form of admin system to populate > the :meta_columns hash with the user-declared options. > > But can anyone suggest any other options that might be worth considering? >I''d start with the simplest solution: class UserAccount < ActiveRecord::Base serialize :meta_data, Hash end Then work up from there as you need more functionality... I''m sure others will recommend larger, more full featured solutions, but simple serialization may work for you/others reading this thread in the future. Cheers, Andy -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
agree, eav, is build based on data serialization try it, if u will be required more, than simply switching to eav Ivan Nastyukhin dieinzige-BUHhN+a2lJ4@public.gmane.org On Jun 3, 2010, at 6:15 PM, Andy Jeffries wrote:> On 3 June 2010 15:06, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > I''ve a requirement to put some user-managed attributes on a model. > > Essentially, I want Entity-Attribute-Value functionality - the > administrator has the ability to create "fields" on the model, and to > specify their type (datetime, string, boolean, decimal, etc). Then in > the regular views, those fields are show in addition to all the normal > fields from the model''s table. This could work with a :has_many > relationship; with the parent model having an overloaded "method > missing" call to look for any members of the associated attributes > that match called-for methods. > > I could roll-my-own, but thought I''d look at any existing EAV options > first; but have found thin pickings! > There''s a fork of "acts_as_eav_model" on Github [1] which allows for > flexible attributes on models; and to my mind, "all" I need to do to > have this do what I want is have some form of admin system to populate > the :meta_columns hash with the user-declared options. > > But can anyone suggest any other options that might be worth considering? > > I''d start with the simplest solution: > > > class UserAccount < ActiveRecord::Base > serialize :meta_data, Hash > end > > Then work up from there as you need more functionality... > > I''m sure others will recommend larger, more full featured solutions, but simple serialization may work for you/others reading this thread in the future. > > Cheers, > > > Andy > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 3 June 2010 15:15, Andy Jeffries <andy-4Fjv1yF9AWJvmwGHilWZ5bVCufUGDwFn@public.gmane.org> wrote:> class UserAccount < ActiveRecord::Base > serialize :meta_data, Hash > endThat would get it working to demo, but I *know* that they''re going to want to search/filter on the attributes once they have their hands on them, so I''d prefer to start with a DB record per attribute that gets assigned. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
may be watch to documented db? something like mongodb? Ivan Nastyukhin dieinzige-BUHhN+a2lJ4@public.gmane.org On Jun 3, 2010, at 6:20 PM, Michael Pavling wrote:> On 3 June 2010 15:15, Andy Jeffries <andy-4Fjv1yF9AWJvmwGHilWZ5bVCufUGDwFn@public.gmane.org> wrote: >> class UserAccount < ActiveRecord::Base >> serialize :meta_data, Hash >> end > > That would get it working to demo, but I *know* that they''re going to > want to search/filter on the attributes once they have their hands on > them, so I''d prefer to start with a DB record per attribute that gets > assigned. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > > class UserAccount < ActiveRecord::Base > > serialize :meta_data, Hash > > end > > That would get it working to demo, but I *know* that they''re going to > want to search/filter on the attributes once they have their hands on > them, so I''d prefer to start with a DB record per attribute that gets > assigned. >Fair enough. I''ve not needed to do it yet, so I''ll bow out (just thought I''d post the simple solution in case someone out there finds this thread and didn''t know about it). Good luck chap. Cheers, Andy -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling wrote:> On 3 June 2010 15:15, Andy Jeffries <andy-4Fjv1yF9AWJvmwGHilWZ5bVCufUGDwFn@public.gmane.org> wrote: >> class UserAccount < ActiveRecord::Base >> serialize :meta_data, Hash >> end > > That would get it working to demo, but I *know*Really? Or do you guess?> that they''re going to > want to search/filter on the attributes once they have their hands on > them, so I''d prefer to start with a DB record per attribute that gets > assigned.EAV is generally a bad idea. If serialize won''t work for you, then your best bet is probably a schemaless non-SQL database such as MongoDB or TokyoCabinet. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.