Why does the generated rails model doesn''t have attributes? How does the rails know what attributes a model has? In railstutorials.org says that the ActiveRecord scans the columns of the associated table of the model and thru that it can know the attributes a model has. Is there more info about this? -- 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.
maiah wrote in post #1019231:> Why does the generated rails model doesn''t have attributes? How does > the rails know what attributes a model has? >$ rails generate model User name:string email:string See those things after User??? $ bundle exec rake db:migrate That creates the db from the "migration" created by ''rails generate model''.> > In railstutorials.org says that the ActiveRecord scans the columns of > the associated table of the model and thru that it can know the > attributes a model has. Is there more info about this? >rails calls attr_accessor() in your model for all the columns in the db. -- 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.
On Tue, Aug 30, 2011 at 8:39 AM, maiah <jjmmacariola-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In railstutorials.org says that the ActiveRecord scans the columns of > the associated table of the model and thru that it can know the > attributes a model has. Is there more info about this?Yes, the Rails documentation :-) I''d suggest starting with ActiveRecord::Base. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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.
Thanks! Now I get it. But I prefer to put Annotations so that I can see which attributes a Model has rather cross-checking the table. On Aug 31, 12:36 am, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Aug 30, 2011 at 8:39 AM, maiah <jjmmacari...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > In railstutorials.org says that the ActiveRecord scans the columns of > > the associated table of the model and thru that it can know the > > attributes a model has. Is there more info about this? > > Yes, the Rails documentation :-) > > I''d suggest starting with ActiveRecord::Base. > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe80Tx58lXaADg@public.gmane.org://about.me/hassanschroeder > twitter: @hassan-- 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.