Hi, i try to implement a Profile System for the users into my Rails App. i want to implement it with these models: class Profile < ActiveRecord::Base has_many :Profileships has_many :users, :through => :Profileships # Gehört zu einer Profil Gruppe belongs_to :profile_group end class Profileship < ActiveRecord::Base belongs_to :user belongs_to :Profile end class ProfileGroup < ActiveRecord::Base # Eine Profil Gruppe hat mehrere Profile has_many :profiles end So a user can edit his Profile informations of a Profile group, stored in the Profileship Database(there is a value fieldin the Profileship table). Do you think this is a good solution, or should i manage the Profile informations in one model and avoid the :has_many_through thing? How should i handle the views, because i think i have to setup a view for every Profilegroup, because i cant build them dynamical, because i can''t figure out if a information needs a input or a textare or .... . -- 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.
PsiPro
2010-Jan-12 16:03 UTC
Re: How to handle Profile Informations with :has_many_through ?
What you have setup there is a Many to Many association. Is that really what you want? Can one profile belong to multiple users? If you give us a better understanding of your end goal we may be able to help more. On Jan 12, 9:32 am, LeonS <leonard.stellbr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > i try to implement a Profile System for the users into my Rails App. > i want to implement it with these models: > > class Profile < ActiveRecord::Base > has_many :Profileships > has_many :users, :through => :Profileships > # Gehört zu einer Profil Gruppe > belongs_to :profile_group > end > > class Profileship < ActiveRecord::Base > belongs_to :user > belongs_to :Profile > end > > class ProfileGroup < ActiveRecord::Base > # Eine Profil Gruppe hat mehrere Profile > has_many :profiles > end > > So a user can edit his Profile informations of a Profile group, stored > in the Profileship Database(there is a value fieldin the Profileship > table). > Do you think this is a good solution, or should i manage the Profile > informations in one model and avoid the :has_many_through thing? > How should i handle the views, because i think i have to setup a view > for every Profilegroup, because i cant build them dynamical, because i > can''t figure out if a information needs a input or a textare or .... .-- 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.
LeonS
2010-Jan-12 16:33 UTC
Re: How to handle Profile Informations with :has_many_through ?
Thats right, because every User has the same profile fields , the possible Profile fields are saved in the Profile model. The value of a profile field of one user is saved in the Profileship model in the field "value". So how can i put that in a view based on the Profilegroup? -- 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.
Marnen Laibow-Koser
2010-Jan-12 16:50 UTC
Re: How to handle Profile Informations with :has_many_throug
LeonS wrote:> Thats right, because every User has the same profile fields , the > possible Profile fields are saved in the Profile model. > The value of a profile field of one user is saved in the Profileship > model in the field "value". > So how can i put that in a view based on the Profilegroup?What on earth are you trying to achieve? What is a profile group for? How do you want this to work from the user''s perspective? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. --001485e9a5701da05f047cfa7553 Content-Type: text/plain; charset=ISO-8859-1 -- 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. --001485e9a5701da05f047cfa7553--
So, for example there are profile field for work, main profile fields, contact field (msn, email, adress....) and so. So i think there is usage for the user. On 12 Jan., 17:50, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> LeonS wrote: > > Thats right, because every User has the same profile fields , the > > possible Profile fields are saved in the Profile model. > > The value of a profile field of one user is saved in the Profileship > > model in the field "value". > > So how can i put that in a view based on the Profilegroup? > > What on earth are you trying to achieve? What is a profile group for? > > How do you want this to work from the user''s perspective? > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Jan-12 18:17 UTC
Re: How to handle Profile Informations with :has_many_throug
LeonS wrote:> So, for example there are profile field for work, main profile fields, > contact field (msn, email, adress....) and soThese could all be in the User model or, failing that, in a separate Profile model where User has_one :profile. Why do you need Profileship and ProfileGroup?> So i think there is usage for the user.Not as far as you''ve explained. Please explain more clearly if I''ve missed something. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. --001485e9a57084be06047cfbaaad Content-Type: text/plain; charset=ISO-8859-1 -- 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. --001485e9a57084be06047cfbaaad--
Let me explain Why i Write the Models: i''m Coming from Database Development, so normalization is very Important for me. If i create just a Profile Model and put all possible profile Fields into that, than there is no normalization Should i avoid the normalization in Case of RoR and keep the Models assimple As possible? On 12 Jan., 19:17, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> LeonS wrote: > > So, for example there are profile field for work, main profile fields, > > contact field (msn, email, adress....) and so > > These could all be in the User model or, failing that, in a separate > Profile model where User has_one :profile. Why do you need Profileship > and ProfileGroup? > > > So i think there is usage for the user. > > Not as far as you''ve explained. Please explain more clearly if I''ve > missed something. > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Jan-12 20:12 UTC
Re: How to handle Profile Informations with :has_many_throug
LeonS wrote:> Let me explain Why i Write the Models: > i''m Coming from Database Development, so normalization is very > Important for me.To me too.> If i create just a Profile Model and put all possible profile Fields > into that, than there is no normalizationOf course there is. Won''t every user have the same set of profile fields? If not, what is your use case? No theory for the moment, just an actual example.> Should i avoid the normalization in Case of RoR and keep the Models > assimple As possible?No, you should normalize without overcomplicating. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. --000325558e16e9ae82047cfd4586 Content-Type: text/plain; charset=ISO-8859-1 -- 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. --000325558e16e9ae82047cfd4586--