I have 2 distinct types of users (artists and curators) in my system and they currently share all associations (eg has_one :portfolio). However, a curator shouldn''t have a portfolio so I would like to only add that association when required. Obviously I could just return nil for that method, but it doesn''t feel right having that there in the first place. What''s the best way to get around this? I''ve looked at using eval in after_find to call the has_one, but couldn''t get it working. Any thoughts? thanks! -- 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 https://groups.google.com/groups/opt_out.
tamouse mailing lists
2012-Dec-25 01:23 UTC
Re: Bad idea to add/remove associations in after_find
On Mon, Dec 24, 2012 at 5:28 PM, Paul Olivers <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have 2 distinct types of users (artists and curators) in my system and > they currently share all associations (eg has_one :portfolio). > However, a curator shouldn''t have a portfolio so I would like to only > add that association when required. Obviously I could just return nil > for that method, but it doesn''t feel right having that there in the > first place. > > What''s the best way to get around this? I''ve looked at using eval in > after_find to call the has_one, but couldn''t get it working. > > Any thoughts?Can an artist also be a curator? -- 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 https://groups.google.com/groups/opt_out.
Frederick Cheung
2012-Dec-25 12:14 UTC
Re: Bad idea to add/remove associations in after_find
On Dec 24, 11:28 pm, Paul Olivers <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have 2 distinct types of users (artists and curators) in my system and > they currently share all associations (eg has_one :portfolio). > However, a curator shouldn''t have a portfolio so I would like to only > add that association when required. Obviously I could just return nil > for that method, but it doesn''t feel right having that there in the > first place. > > What''s the best way to get around this? I''ve looked at using eval in > after_find to call the has_one, but couldn''t get it working.Have you considered STI ? Fred> > Any thoughts? > > thanks! > > -- > Posted viahttp://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@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Dheeraj Kumar
2012-Dec-25 12:17 UTC
Re: Re: Bad idea to add/remove associations in after_find
+1 for STI, if an artist cannot be a curator. Roles with CanCan, if an artist can be a curator. -- Dheeraj Kumar On Tuesday 25 December 2012 at 5:44 PM, Frederick Cheung wrote:> > > On Dec 24, 11:28 pm, Paul Olivers <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org (http://ruby-forum.com)> wrote: > > I have 2 distinct types of users (artists and curators) in my system and > > they currently share all associations (eg has_one :portfolio). > > However, a curator shouldn''t have a portfolio so I would like to only > > add that association when required. Obviously I could just return nil > > for that method, but it doesn''t feel right having that there in the > > first place. > > > > What''s the best way to get around this? I''ve looked at using eval in > > after_find to call the has_one, but couldn''t get it working. > > > > > Have you considered STI ? > > Fred > > > > > Any thoughts? > > > > thanks! > > > > -- > > Posted viahttp://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 (mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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 https://groups.google.com/groups/opt_out.
better use cancan also you can create type filed make polymorphic ossification and create different users of different roles On Tue, Dec 25, 2012 at 5:47 PM, Dheeraj Kumar <a.dheeraj.kumar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> +1 for STI, if an artist cannot be a curator. > Roles with CanCan, if an artist can be a curator. > > -- > Dheeraj Kumar > > On Tuesday 25 December 2012 at 5:44 PM, Frederick Cheung wrote: > > > > On Dec 24, 11:28 pm, Paul Olivers <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > I have 2 distinct types of users (artists and curators) in my system and > they currently share all associations (eg has_one :portfolio). > However, a curator shouldn''t have a portfolio so I would like to only > add that association when required. Obviously I could just return nil > for that method, but it doesn''t feel right having that there in the > first place. > > What''s the best way to get around this? I''ve looked at using eval in > after_find to call the has_one, but couldn''t get it working. > > > Have you considered STI ? > > Fred > > > Any thoughts? > > thanks! > > -- > Posted viahttp://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 https://groups.google.com/groups/opt_out. > > > -- > 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 https://groups.google.com/groups/opt_out. > > >-- 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 https://groups.google.com/groups/opt_out.