Is it too much to ask to make this method raise and exception/call super if it''s not a recognized method pattern? David
You can do this yourself by simply redefining ActionMailer#method_missing to do whatever you see fit. All this is made possible as classes are open in Ruby, you can add new methods or modify existing ones too. Zsombor On 7/5/05, David Corbin <dcorbin-wmGZ+vDKSyrZJqsBc5GL+g@public.gmane.org> wrote:> Is it too much to ask to make this method raise and exception/call super if > it''s not a recognized method pattern? > > David > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- http://deezsombor.blogspot.com
> Is it too much to ask to make this method raise and exception/call super if > it''s not a recognized method pattern?I''d take a patch on something that did that. -- David Heinemeier Hansson http://www.loudthinking.com -- Broadcasting Brain http://www.basecamphq.com -- Online project management http://www.backpackit.com -- Personal information manager http://www.rubyonrails.com -- Web-application framework
On Jul 5, 2005, at 7:09 AM, David Heinemeier Hansson wrote:>> Is it too much to ask to make this method raise and exception/call >> super if >> it''s not a recognized method pattern? >> > > I''d take a patch on something that did that.Actually, HEAD already delegates unknown patterns to the superclass, which will raise exceptions if the method isn''t found. Thus: * create_xxx tries to simply create and return a new mail object for the named action * deliver_xxx tries to create and deliver a new mail object for the named action * new is ignored (it''s a private method now, but for backwards compatibility method_missing just has it return nil) Everything else is sent to the superclass. - Jamis
Hello, Apologies for the newbie question. I''ve had a dig around and done some solid searching but can''t see the answer. Timestamp data is stored in my Postgres database like this: 2005-01-05 18:32:28+00 My Rails application displays the same timestamp field like this: Wed Jan 05 18:32:28 EST 2005 At what point between the database and the webserver is this timestamp being formatted? Can anyone suggest what is the "rails approved" way to format timestamps in the way that I want, which is this: Wed 05 Jan 2005 Thanks Andrew Stuart
On Jul 5, 2005, at 7:14 PM, Andrew Stuart wrote:> Hello, > > Apologies for the newbie question. I''ve had a dig around and done some > solid searching but can''t see the answer. > > Timestamp data is stored in my Postgres database like this: > 2005-01-05 18:32:28+00 > > My Rails application displays the same timestamp field like this: > Wed Jan 05 18:32:28 EST 2005 > > At what point between the database and the webserver is this timestamp > being > formatted? > > Can anyone suggest what is the "rails approved" way to format > timestamps in > the way that I want, which is this: > Wed 05 Jan 2005 > > Thanks > > Andrew Stuart >AR will hand you a Time object so use strftime, as such <%= post.created_at.strftime(''%D'') %> It''s part of Ruby and documented there. -Scott _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
When a date is pulled out of the database it is made into a DateTime object. What your getting is the result of DateTime.to_str To format it use DateTime.strftime(format_string) Look here for more information: http://www.ruby-doc.org/stdlib/ On Jul 5, 2005, at 4:14 PM, Andrew Stuart wrote:> Hello, > > Apologies for the newbie question. I''ve had a dig around and done > some > solid searching but can''t see the answer. > > Timestamp data is stored in my Postgres database like this: > 2005-01-05 18:32:28+00 > > My Rails application displays the same timestamp field like this: > Wed Jan 05 18:32:28 EST 2005 > > At what point between the database and the webserver is this > timestamp being > formatted? > > Can anyone suggest what is the "rails approved" way to format > timestamps in > the way that I want, which is this: > Wed 05 Jan 2005 > > Thanks > > Andrew Stuart > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
The Rails book also recommends creating a help function to deal with formatting values (so they can be refactored easiliy) On 7/5/05, Russ Smith <russ-Bff6KPpgmvsxnA8XTFIEbw@public.gmane.org> wrote:> When a date is pulled out of the database it is made into a DateTime > object. What your getting is the result of DateTime.to_str > > To format it use DateTime.strftime(format_string) > > Look here for more information: http://www.ruby-doc.org/stdlib/ > > > On Jul 5, 2005, at 4:14 PM, Andrew Stuart wrote: > > > Hello, > > > > Apologies for the newbie question. I''ve had a dig around and done > > some > > solid searching but can''t see the answer. > > > > Timestamp data is stored in my Postgres database like this: > > 2005-01-05 18:32:28+00 > > > > My Rails application displays the same timestamp field like this: > > Wed Jan 05 18:32:28 EST 2005 > > > > At what point between the database and the webserver is this > > timestamp being > > formatted? > > > > Can anyone suggest what is the "rails approved" way to format > > timestamps in > > the way that I want, which is this: > > Wed 05 Jan 2005 > > > > Thanks > > > > Andrew Stuart > > > > _______________________________________________ > > 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 >
I know I can do that. but to me, it''s a minor flaw in the Rails code. This should be standard for all the ''dynamically generated methods''. On Tuesday 05 July 2005 03:41 am, Dee Zsombor wrote:> You can do this yourself by simply redefining > ActionMailer#method_missing to do whatever you see fit. All this is > made possible as classes are open in Ruby, you can add new methods or > modify existing ones too. > > Zsombor > > On 7/5/05, David Corbin <dcorbin-wmGZ+vDKSyrZJqsBc5GL+g@public.gmane.org> wrote: > > Is it too much to ask to make this method raise and exception/call super > > if it''s not a recognized method pattern? > > > > David > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails