Hi, Does anyone know a way to override .blank? method that rails provides. I want to add additional custom checks (specific to my application) to this method. Thanks, Pratik
> Does anyone know a way to override .blank? method that rails provides. > I want to add additional custom checks (specific to my application) to > this method.I''d tread very carefully here. I know I use .blank? all over the place. I imagine Rails and lots of plugins do as well. You may well be changing behavior in libraries you''re not aware of... I''d suggest if at all possible to create your own .my_blank? method (with a better name of course) and use that where appropriate. Otherwise... search the rails source for "def blank?" and then simply override it by monkey patching it.
Hi Philip, I am reasonably new to rails, i''ve fallen in love with it :). Reading your response, though I understand what your saying but I don''t have enough knowledge on how one can do something like that, could you be generous enough to share some resource links or something where I could read something about it? Thanks! Thanks & Regards, Dhruva Sagar. Stephen Leacock<http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html> - "I detest life-insurance agents: they always argue that I shall some day die, which is not so." On Tue, Aug 25, 2009 at 5:29 AM, Philip Hallstrom <philip-LSG90OXdqQE@public.gmane.org> wrote:> > > Does anyone know a way to override .blank? method that rails provides. > > I want to add additional custom checks (specific to my application) to > > this method. > > I''d tread very carefully here. I know I use .blank? all over the > place. I imagine Rails and lots of plugins do as well. You may well > be changing behavior in libraries you''re not aware of... > > I''d suggest if at all possible to create your own .my_blank? method > (with a better name of course) and use that where appropriate. > > Otherwise... search the rails source for "def blank?" and then simply > override it by monkey patching it. > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2009/8/25 Dhruva Sagar <dhruva.sagar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Hi Philip, > I am reasonably new to rails, i''ve fallen in love with it :). > Reading your response, though I understand what your saying but I don''t have > enough knowledge on how one can do something like that,Since you top posted your comment it is unclear which ''something like that'' you are referring to. Is it creating a method my_blank? or monkey patching that you want help with? Colin> could you be > generous enough to share some resource links or something where I could read > something about it? > Thanks! > Thanks & Regards, > Dhruva Sagar. > > > Stephen Leacock - "I detest life-insurance agents: they always argue that I > shall some day die, which is not so." > > On Tue, Aug 25, 2009 at 5:29 AM, Philip Hallstrom <philip-LSG90OXdqQE@public.gmane.org> wrote: >> >> > Does anyone know a way to override .blank? method that rails provides. >> > I want to add additional custom checks (specific to my application) to >> > this method. >> >> I''d tread very carefully here. I know I use .blank? all over the >> place. I imagine Rails and lots of plugins do as well. You may well >> be changing behavior in libraries you''re not aware of... >> >> I''d suggest if at all possible to create your own .my_blank? method >> (with a better name of course) and use that where appropriate. >> >> Otherwise... search the rails source for "def blank?" and then simply >> override it by monkey patching it. >> >> > > > > >
Oh I am sorry for that, my mistake!!I wanted some info regarding monkey patching... Thanks & Regards, Dhruva Sagar. Ogden Nash <http://www.brainyquote.com/quotes/authors/o/ogden_nash.html> - "The trouble with a kitten is that when it grows up, it''s always a cat." On Tue, Aug 25, 2009 at 2:47 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > 2009/8/25 Dhruva Sagar <dhruva.sagar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > Hi Philip, > > I am reasonably new to rails, i''ve fallen in love with it :). > > Reading your response, though I understand what your saying but I don''t > have > > enough knowledge on how one can do something like that, > > Since you top posted your comment it is unclear which ''something like > that'' you are referring to. Is it creating a method my_blank? or > monkey patching that you want help with? > > Colin > > > could you be > > generous enough to share some resource links or something where I could > read > > something about it? > > Thanks! > > Thanks & Regards, > > Dhruva Sagar. > > > > > > Stephen Leacock - "I detest life-insurance agents: they always argue > that I > > shall some day die, which is not so." > > > > On Tue, Aug 25, 2009 at 5:29 AM, Philip Hallstrom <philip-LSG90OXdqQE@public.gmane.org> > wrote: > >> > >> > Does anyone know a way to override .blank? method that rails provides. > >> > I want to add additional custom checks (specific to my application) to > >> > this method. > >> > >> I''d tread very carefully here. I know I use .blank? all over the > >> place. I imagine Rails and lots of plugins do as well. You may well > >> be changing behavior in libraries you''re not aware of... > >> > >> I''d suggest if at all possible to create your own .my_blank? method > >> (with a better name of course) and use that where appropriate. > >> > >> Otherwise... search the rails source for "def blank?" and then simply > >> override it by monkey patching it. > >> > >> > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2009/8/25 Dhruva Sagar <dhruva.sagar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Oh I am sorry for that, my mistake!! > I wanted some info regarding monkey patching... > Thanks & Regards, > Dhruva Sagar.Google for ''how to monkey patch rails'', it throws up lots of useful links, though no doubt some are more useful than others. Colin> > > Ogden Nash - "The trouble with a kitten is that when it grows up, it''s > always a cat." > > On Tue, Aug 25, 2009 at 2:47 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> 2009/8/25 Dhruva Sagar <dhruva.sagar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> > Hi Philip, >> > I am reasonably new to rails, i''ve fallen in love with it :). >> > Reading your response, though I understand what your saying but I don''t >> > have >> > enough knowledge on how one can do something like that, >> >> Since you top posted your comment it is unclear which ''something like >> that'' you are referring to. Is it creating a method my_blank? or >> monkey patching that you want help with? >> >> Colin >> >> > could you be >> > generous enough to share some resource links or something where I could >> > read >> > something about it? >> > Thanks! >> > Thanks & Regards, >> > Dhruva Sagar. >> > >> > >> > Stephen Leacock - "I detest life-insurance agents: they always argue >> > that I >> > shall some day die, which is not so." >> > >> > On Tue, Aug 25, 2009 at 5:29 AM, Philip Hallstrom <philip-LSG90OXdqQE@public.gmane.org> >> > wrote: >> >> >> >> > Does anyone know a way to override .blank? method that rails >> >> > provides. >> >> > I want to add additional custom checks (specific to my application) >> >> > to >> >> > this method. >> >> >> >> I''d tread very carefully here. I know I use .blank? all over the >> >> place. I imagine Rails and lots of plugins do as well. You may well >> >> be changing behavior in libraries you''re not aware of... >> >> >> >> I''d suggest if at all possible to create your own .my_blank? method >> >> (with a better name of course) and use that where appropriate. >> >> >> >> Otherwise... search the rails source for "def blank?" and then simply >> >> override it by monkey patching it. >> >> >> >> >> > >> > >> > > >> > >> >> > > > > >
:-|, yea I did that anyways, did go through some stuff, will go through some more at night when I have more free time.Just wanted to get some good references or leads which others have already used perhaps ... Thanks & Regards, Dhruva Sagar. Charles de Gaulle<http://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html> - "The better I get to know men, the more I find myself loving dogs." On Tue, Aug 25, 2009 at 3:03 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> how to monkey patch rails--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2009/8/25 Dhruva Sagar <dhruva.sagar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> :-|, yea I did that anyways, did go through some stuff, will go through some > more at night when I have more free time. > Just wanted to get some good references or leads which others have already > used perhaps ... > Thanks & Regards,Apologies, you would be surprised how many don''t do their own research first. Colin> Dhruva Sagar. > > > Charles de Gaulle - "The better I get to know men, the more I find myself > loving dogs." > > On Tue, Aug 25, 2009 at 3:03 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> how to monkey patch rails > > > >
If you just want to add checks for a single model, you can override blank? on the model. Just declare it like any other method. --Matt Jones On Aug 24, 7:49 pm, tispratik <tispra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > Does anyone know a way to override .blank? method that rails provides. > I want to add additional custom checks (specific to my application) to > this method. > > Thanks, > Pratik