Hi, I''m getting a datetime field from my db which I want to format in my .rhtml view. After some searching, I tried the following which works fine: <% d = @licence[''expiry_date''] %> <%= "#{d.day}/#{d.month}/#{d.year}" %> But is it the ''Ruby on Rails'' way? All comments welcome. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
If datetime fields are a Time class then you could do this: <%= @licence[''expiry_date''].strftime("%m/%d/%Y") %> see http://www.rubycentral.com/ref/ref_c_time.html#strftime for other options. Charles Comstock On Tue, 22 Mar 2005 16:55:31 +1100, Neville Burnell <Neville.Burnell-uEDVyssJ3mUpAS55Wn97og@public.gmane.org> wrote:> > > Hi, > > I''m getting a datetime field from my db which I want to format in my .rhtml > view. > > After some searching, I tried the following which works fine: > > <% d = @licence[''expiry_date''] %> > <%= "#{d.day}/#{d.month}/#{d.year}" %> > > But is it the ''Ruby on Rails'' way? > > All comments welcome. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
On Tue, 22 Mar 2005 01:03:39 -0600, Charles Comstock <dgtized-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If datetime fields are a Time class then you could do this: > > <%= @licence[''expiry_date''].strftime("%m/%d/%Y") %>If @license is an active record object, you should do @license.expiry_date.strftime("%m/%d/%Y")> see http://www.rubycentral.com/ref/ref_c_time.html#strftime for other options. > > Charles Comstock > > On Tue, 22 Mar 2005 16:55:31 +1100, Neville Burnell > <Neville.Burnell-uEDVyssJ3mUpAS55Wn97og@public.gmane.org> wrote: > > > > > > Hi, > > > > I''m getting a datetime field from my db which I want to format in my .rhtml > > view. > > > > After some searching, I tried the following which works fine: > > > > <% d = @licence[''expiry_date''] %> > > <%= "#{d.day}/#{d.month}/#{d.year}" %> > > > > But is it the ''Ruby on Rails'' way? > > > > All comments welcome. > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
Hi I''m using "script/generate scaffold table_name" which generates correct show and list actions, but the edit and new actions are missing the required input textbox fields, i.e. I have to manually add "<%= text_field "cow", "Name", "size" => 20 %>" to the .rhtml. Am I doing something wrong, or is this an issue with the generator? Thanks Michael _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Is this happening with the new 0.11? The scaffold generator changed to put the form into a partial ( _form.rhml ). Is this maybe the case? On Tue, 22 Mar 2005 11:09:24 +0000, Michael Champanis <michael-MXk1+JRFB8SsTnJN9+BGXg@public.gmane.org> wrote:> Hi > > I''m using "script/generate scaffold table_name" which generates correct > show and list actions, > but the edit and new actions are missing the required input textbox fields, > i.e. I have to manually > add "<%= text_field "cow", "Name", "size" => 20 %>" to the .rhtml. > > Am I doing something wrong, or is this an issue with the generator? > > Thanks > Michael > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog
Thanks ... I''m running with @license.expiry_date.strftime("%m/%d/%Y") This ''way'' appeals to me because it reads more cleanly than the hash lookup ... -----Original Message----- From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Michael Koziarski Sent: Tuesday, 22 March 2005 7:23 PM To: Charles Comstock; rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] Formatting dates with erb On Tue, 22 Mar 2005 01:03:39 -0600, Charles Comstock <dgtized-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If datetime fields are a Time class then you could do this: > > <%= @licence[''expiry_date''].strftime("%m/%d/%Y") %>If @license is an active record object, you should do @license.expiry_date.strftime("%m/%d/%Y")> see http://www.rubycentral.com/ref/ref_c_time.html#strftime for otheroptions.> > Charles Comstock > > On Tue, 22 Mar 2005 16:55:31 +1100, Neville Burnell > <Neville.Burnell-uEDVyssJ3mUpAS55Wn97og@public.gmane.org> wrote: > > > > > > Hi, > > > > I''m getting a datetime field from my db which I want to format in my> > .rhtml view. > > > > After some searching, I tried the following which works fine: > > > > <% d = @licence[''expiry_date''] %> > > <%= "#{d.day}/#{d.month}/#{d.year}" %> > > > > But is it the ''Ruby on Rails'' way? > > > > All comments welcome. > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I''ve got 0.11 running now and it is behaving the same as 0.10.1. I run "script/generate scaffold country", and it generates all the files, but my new and edit action pages are still missing any form of input box that I can change/add data with. I have to add them all by hand. Thanks Mike> Is this happening with the new 0.11? > > The scaffold generator changed to put the form into a partial ( _form.rhml ). > Is this maybe the case? > > > On Tue, 22 Mar 2005 11:09:24 +0000, Michael Champanis > <michael-MXk1+JRFB8SsTnJN9+BGXg@public.gmane.org> wrote: > > Hi > > > > I''m using "script/generate scaffold table_name" which generates correct > > show and list actions, > > but the edit and new actions are missing the required input textbox fields, > > i.e. I have to manually > > add "<%= text_field "cow", "Name", "size" => 20 %>" to the .rhtml. > > > > Am I doing something wrong, or is this an issue with the generator? > > > > Thanks > > Michael_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Which database is that? On Wed, 23 Mar 2005 11:38:18 +0000, Michael Champanis <michael-MXk1+JRFB8SsTnJN9+BGXg@public.gmane.org> wrote:> I''ve got 0.11 running now and it is behaving the same as 0.10.1. > I run "script/generate scaffold country", and it generates all the files, > but my new and edit action pages are still missing any form of input box > that > I can change/add data with. I have to add them all by hand. > > Thanks > Mike > > > > Is this happening with the new 0.11? The scaffold generator changed to put > the form into a partial ( _form.rhml ). Is this maybe the case? On Tue, 22 > Mar 2005 11:09:24 +0000, Michael Champanis <michael-MXk1+JRFB8SsTnJN9+BGXg@public.gmane.org> wrote: > Hi > > > I''m using "script/generate scaffold table_name" which generates correct > > show and list actions, > but the edit and new actions are missing the > required input textbox fields, > i.e. I have to manually > add "<%> text_field "cow", "Name", "size" => 20 %>" to the .rhtml. > > Am I doing > something wrong, or is this an issue with the generator? > > Thanks > > Michael > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog
It''s postgresql 8.0.1. I''ve opened a ticket: http://dev.rubyonrails.com/ticket/913> Which database is that? > > > On Wed, 23 Mar 2005 11:38:18 +0000, Michael Champanis > <michael-MXk1+JRFB8SsTnJN9+BGXg@public.gmane.org> wrote: > > I''ve got 0.11 running now and it is behaving the same as 0.10.1. > > I run "script/generate scaffold country", and it generates all the files, > > but my new and edit action pages are still missing any form of input box > > that > > I can change/add data with. I have to add them all by hand. > > > > Thanks > > Mike_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails