Im setting up a very basic rails app and have a question about the needed migrations & associations. Basically, my app is an occasion reminder service that emails users when occasions that they select or input are coming up. Occasions will be selected from a checkbox type list or alternatively manually input by the user (name and date of the occasion). Users can have_many occassions. How would i set this up in my models? So far i have: class Reminder < ActiveRecord::Base attr_accessible :date, :name belongs_to :user end class User < ActiveRecord::Base attr_accessible :address, :birthday, :city, :email, :gender, :interests, :name, :postal_code has_many :reminders end Thanks! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/lDjtqP256lQJ. 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 4 May 2012 05:50, Nelson Keating <nelsonkeating-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Im setting up a very basic rails app and have a question about the needed > migrations & associations. > > Basically, my app is an occasion reminder service that emails users when > occasions that they select or input are coming up. > > Occasions will be selected from a checkbox type list or alternatively > manually input by the user (name and date of the occasion). > > Users can have_many occassions. > > How would i set this up in my models? So far i have: > > class Reminder < ActiveRecord::Base > attr_accessible :date, :name > belongs_to :user > end > > class User < ActiveRecord::Base > attr_accessible :address, :birthday, :city, :email, :gender, :interests, > :name, :postal_code > has_many :reminders > endYou seem confused about the words Reminder and Occasion. In the text you say a user has many occasions but in the code you have called them Reminders. I would have thought that the object in the database is an occasion, then you generate reminders for that occasion as required. Colin -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for pointing that out.. so changing the "Reminders" table/model to "Occasions" ... how would i proceed from there? On Thursday, May 3, 2012 9:50:34 PM UTC-7, Nelson Keating wrote:> > Im setting up a very basic rails app and have a question about the needed > migrations & associations. > > Basically, my app is an occasion reminder service that emails users when > occasions that they select or input are coming up. > > Occasions will be selected from a checkbox type list or alternatively > manually input by the user (name and date of the occasion). > > Users can have_many occassions. > > How would i set this up in my models? So far i have: > > class Reminder < ActiveRecord::Base > attr_accessible :date, :name > belongs_to :user > end > > class User < ActiveRecord::Base > attr_accessible :address, :birthday, :city, :email, :gender, :interests, > :name, :postal_code > has_many :reminders > end > > > Thanks! >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/_La4pquupJ8J. 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 4 May 2012 18:38, Nelson Keating <nelsonkeating-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for pointing that out.. so changing the "Reminders" table/model to > "Occasions" ... how would i proceed from there?Have you worked through some tutorials to give you some insight into the basics of Rails? railstutorial.org is good and is free to use online. If you work right through that, doing the exercises and so on then you should be better placed to get going. Colin> > > On Thursday, May 3, 2012 9:50:34 PM UTC-7, Nelson Keating wrote: >> >> Im setting up a very basic rails app and have a question about the needed >> migrations & associations. >> >> Basically, my app is an occasion reminder service that emails users when >> occasions that they select or input are coming up. >> >> Occasions will be selected from a checkbox type list or alternatively >> manually input by the user (name and date of the occasion). >> >> Users can have_many occassions. >> >> How would i set this up in my models? So far i have: >> >> class Reminder < ActiveRecord::Base >> attr_accessible :date, :name >> belongs_to :user >> end >> >> class User < ActiveRecord::Base >> attr_accessible :address, :birthday, :city, :email, :gender, :interests, >> :name, :postal_code >> has_many :reminders >> end >> >> >> Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/_La4pquupJ8J. > > 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.