Hi all, My model: user has many events through statistics and registrations registrations contains whether or not the user was on the event, statistics contains what he did on the event. I think it is better to make 2 tables since I don''t need a statistics record if the user was not present (registration.present = 0). But maybe someone has an other view ont this? I want to create a eventview (show) where an admin can enter/change the event data. The admin should be able to insert whether the user was present (with a checkbox) and if present a form is shown on the same row where the statistics data can be entered (minutes present, ...). I''m trying to edit 2 models here: statistics and registrations. The problem is that I don''t really have a clue on where to start. Maybe Someone can point me in the good direction? thanks Stijn --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe you could just stick with a User and Events model. Then each has_and_belongs_to_many :events/:users. -Ryan On Jan 31, 10:35 am, Tarscher <tarsc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > My model: > user has many events through statistics and registrations > > registrations contains whether or not the user was on the event, > statistics contains what he did on the event. > > I think it is better to make 2 tables since I don''t need a statistics > record if the user was not present (registration.present = 0). But > maybe someone has an other view ont this? > > I want to create a eventview (show) where an admin can enter/change > the event data. The admin should be able to insert whether the user > was present (with a checkbox) and if present a form is shown on the > same row where the statistics data can be entered (minutes > present, ...). > > I''m trying to edit 2 models here: statistics and registrations. > > The problem is that I don''t really have a clue on where to start. > > Maybe Someone can point me in the good direction? > > thanks > Stijn--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
registrations contains whether or not the user was on the event, statistics contains what he did on the event. So basically, if user was at event registration = yes statistics = data on user''s attendence else registration = no end It seems like your registration model''s primary purpose is to indicate whether attendance occurred, thus creating the need for a statistics entry. Instead, you should do: a user :has_many :events, :through => :attendances attendance will do everything that your statistics model does. more importantly, its _presence_ indicates that a registration occurred, and if it''s not there, it means that a registration has not occurred. Regardless of whether I understood your problem or not: using models for join tables (HABTM :through relationships) allows you to talk as directly to rails about the _relationship_ between objects as you talk about the objects themselves. This is a powerful and widely-applicable concept. Jim Cropcho On Jan 31, 11:53 am, kopf1988 <kopf1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Maybe you could just stick with a User and Events model. Then each > has_and_belongs_to_many :events/:users. > > -Ryan > > On Jan 31, 10:35 am, Tarscher <tarsc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi all, > > > My model: > > user has many events through statistics and registrations > > > registrations contains whether or not the user was on the event, > > statistics contains what he did on the event. > > > I think it is better to make 2 tables since I don''t need a statistics > > record if the user was not present (registration.present = 0). But > > maybe someone has an other view ont this? > > > I want to create a eventview (show) where an admin can enter/change > > the event data. The admin should be able to insert whether the user > > was present (with a checkbox) and if present a form is shown on the > > same row where the statistics data can be entered (minutes > > present, ...). > > > I''m trying to edit 2 models here: statistics and registrations. > > > The problem is that I don''t really have a clue on where to start. > > > Maybe Someone can point me in the good direction? > > > thanks > > Stijn--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
BTW, YAML form builder: http://www.anup.info/2007/10/13/yaml_form_builder-rails-plugin/ will dynamically insert form markup in eRB inside your views based on YAML specifications. It will speed up construction, and make your forms quite maintainable. On Jan 31, 1:13 pm, Jim Cropcho <jim.crop...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> registrations contains whether or not the user was on the event, > statistics contains what he did on the event. > > So basically, > > if user was at event > registration = yes > statistics = data on user''s attendence > else > registration = no > end > > It seems like your registration model''s primary purpose is to indicate > whether attendance occurred, thus creating the need for a statistics > entry. Instead, you should do: > > a user :has_many :events, :through => :attendances > > attendance will do everything that your statistics model does. more > importantly, its _presence_ indicates that a registration occurred, > and if it''s not there, it means that a registration has not occurred. > > Regardless of whether I understood your problem or not: using models > for join tables (HABTM :through relationships) allows you to talk as > directly to rails about the _relationship_ between objects as you talk > about the objects themselves. This is a powerful and widely-applicable > concept. > > Jim Cropcho > > On Jan 31, 11:53 am, kopf1988 <kopf1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Maybe you could just stick with a User and Events model. Then each > > has_and_belongs_to_many :events/:users. > > > -Ryan > > > On Jan 31, 10:35 am, Tarscher <tarsc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi all, > > > > My model: > > > user has many events through statistics and registrations > > > > registrations contains whether or not the user was on the event, > > > statistics contains what he did on the event. > > > > I think it is better to make 2 tables since I don''t need a statistics > > > record if the user was not present (registration.present = 0). But > > > maybe someone has an other view ont this? > > > > I want to create a eventview (show) where an admin can enter/change > > > the event data. The admin should be able to insert whether the user > > > was present (with a checkbox) and if present a form is shown on the > > > same row where the statistics data can be entered (minutes > > > present, ...). > > > > I''m trying to edit 2 models here: statistics and registrations. > > > > The problem is that I don''t really have a clue on where to start. > > > > Maybe Someone can point me in the good direction? > > > > thanks > > > Stijn--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
check this out as well: http://railscasts.com/episodes/73 On Jan 31, 1:17 pm, Jim Cropcho <jim.crop...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> BTW, YAML form builder: > > http://www.anup.info/2007/10/13/yaml_form_builder-rails-plugin/ > > will dynamically insert form markup in eRB inside your views based on > YAML specifications. It will speed up construction, and make your > forms quite maintainable. > > On Jan 31, 1:13 pm, JimCropcho<jim.crop...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > registrations contains whether or not the user was on the event, > > statistics contains what he did on the event. > > > So basically, > > > if user was at event > > registration = yes > > statistics = data on user''s attendence > > else > > registration = no > > end > > > It seems like your registration model''s primary purpose is to indicate > > whether attendance occurred, thus creating the need for a statistics > > entry. Instead, you should do: > > > a user :has_many :events, :through => :attendances > > > attendance will do everything that your statistics model does. more > > importantly, its _presence_ indicates that a registration occurred, > > and if it''s not there, it means that a registration has not occurred. > > > Regardless of whether I understood your problem or not: using models > > for join tables (HABTM :through relationships) allows you to talk as > > directly to rails about the _relationship_ between objects as you talk > > about the objects themselves. This is a powerful and widely-applicable > > concept. > > > JimCropcho > > > On Jan 31, 11:53 am, kopf1988 <kopf1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Maybe you could just stick with a User and Events model. Then each > > > has_and_belongs_to_many :events/:users. > > > > -Ryan > > > > On Jan 31, 10:35 am, Tarscher <tarsc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi all, > > > > > My model: > > > > user has many events through statistics and registrations > > > > > registrations contains whether or not the user was on the event, > > > > statistics contains what he did on the event. > > > > > I think it is better to make 2 tables since I don''t need a statistics > > > > record if the user was not present (registration.present = 0). But > > > > maybe someone has an other view ont this? > > > > > I want to create a eventview (show) where an admin can enter/change > > > > the event data. The admin should be able to insert whether the user > > > > was present (with a checkbox) and if present a form is shown on the > > > > same row where the statistics data can be entered (minutes > > > > present, ...). > > > > > I''m trying to edit 2 models here: statistics and registrations. > > > > > The problem is that I don''t really have a clue on where to start. > > > > > Maybe Someone can point me in the good direction? > > > > > thanks > > > > Stijn--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
thanks, that railscastis realy helpfull On 4 feb, 02:03, Jim Cropcho <jim.crop...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> check this out as well: > > http://railscasts.com/episodes/73 > > On Jan 31, 1:17 pm, Jim Cropcho <jim.crop...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > BTW, YAML form builder: > > >http://www.anup.info/2007/10/13/yaml_form_builder-rails-plugin/ > > > will dynamically insert form markup in eRB inside your views based on > > YAML specifications. It will speed up construction, and make your > > forms quite maintainable. > > > On Jan 31, 1:13 pm, JimCropcho<jim.crop...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > registrations contains whether or not the user was on the event, > > > statistics contains what he did on the event. > > > > So basically, > > > > if user was at event > > > registration = yes > > > statistics = data on user''s attendence > > > else > > > registration = no > > > end > > > > It seems like your registration model''s primary purpose is to indicate > > > whether attendance occurred, thus creating the need for a statistics > > > entry. Instead, you should do: > > > > a user :has_many :events, :through => :attendances > > > > attendance will do everything that your statistics model does. more > > > importantly, its _presence_ indicates that a registration occurred, > > > and if it''s not there, it means that a registration has not occurred. > > > > Regardless of whether I understood your problem or not: using models > > > for join tables (HABTM :through relationships) allows you to talk as > > > directly to rails about the _relationship_ between objects as you talk > > > about the objects themselves. This is a powerful and widely-applicable > > > concept. > > > > JimCropcho > > > > On Jan 31, 11:53 am, kopf1988 <kopf1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Maybe you could just stick with a User and Events model. Then each > > > > has_and_belongs_to_many :events/:users. > > > > > -Ryan > > > > > On Jan 31, 10:35 am,Tarscher<tarsc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Hi all, > > > > > > My model: > > > > > user has many events through statistics and registrations > > > > > > registrations contains whether or not the user was on the event, > > > > > statistics contains what he did on the event. > > > > > > I think it is better to make 2 tables since I don''t need a statistics > > > > > record if the user was not present (registration.present = 0). But > > > > > maybe someone has an other view ont this? > > > > > > I want to create a eventview (show) where an admin can enter/change > > > > > the event data. The admin should be able to insert whether the user > > > > > was present (with a checkbox) and if present a form is shown on the > > > > > same row where the statistics data can be entered (minutes > > > > > present, ...). > > > > > > I''m trying to edit 2 models here: statistics and registrations. > > > > > > The problem is that I don''t really have a clue on where to start. > > > > > > Maybe Someone can point me in the good direction? > > > > > > thanks > > > > > Stijn--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---