JK
2010-Nov-26 23:54 UTC
Adding date into entries when I do scaffolding [beginner question]
So I would like to add time as an attribute of my Submission using scaffolding. What is the code I should use to replace ???? part? rails generate scaffold Submission title:string describtion:text email:string category:string time:?????? -- 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.
daze
2010-Nov-27 03:13 UTC
Re: Adding date into entries when I do scaffolding [beginner question]
well, you should probably check this out: http://api.rubyonrails.org/classes/ActiveRecord/Timestamp.html It says: "Active Record automatically timestamps create and update operations if the table has fields named created_at/created_on or updated_at/updated_on." On Nov 26, 6:54 pm, JK <jngh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So I would like to add time as an attribute of my Submission using > scaffolding. What is the code I should use to replace ???? part? > > rails generate scaffold Submission title:string describtion:text > email:string category:string time:??????-- 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.
Colin Law
2010-Nov-27 09:34 UTC
Re: Adding date into entries when I do scaffolding [beginner question]
On 26 November 2010 23:54, JK <jnghwan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So I would like to add time as an attribute of my Submission using > scaffolding. What is the code I should use to replace ???? part? > > rails generate scaffold Submission title:string describtion:text > email:string category:string time:??????I would advise against a field name of time, it is in the reserved word list at http://wiki.rubyonrails.org/rails/pages/ReservedWords. In practice you may be ok with lower case time but I would still advise against it. If you need more than the default created_at and updated_at fields provided by rails then you can use the :datetime column type. 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
gezope
2010-Nov-28 11:13 UTC
Re: Adding date into entries when I do scaffolding [beginner question]
Hello, time:date or time:datetime, depends on which type of data do you want to hold in your database. Check also how to create a migration whihc change your model and database structure: http://guides.rubyonrails.org/migrations.html Preferabyl go through a tutorial, you wwill know the differences between generators also, now only scaffolding. And check the files which created by scaffold generator. cheers, Zoltán On nov. 26, 23:54, JK <jngh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So I would like to add time as an attribute of my Submission using > scaffolding. What is the code I should use to replace ???? part? > > rails generate scaffold Submission title:string describtion:text > email:string category:string time:??????-- 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.