hi guys i am checking with params[:a].nil? and params[:a].blank? but in the url a is not coming but for some other purpose service i am using the same a for some other service if some params is nit coming in url how to check guide me -- Karthik.k Mobile - +91-9894991640 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Karthik Kantharaj wrote:> hi guys > > i am checking with params[:a].nil? and params[:a].blank? > > but in the url a is not coming but for some other purpose service i am > using > the same a for some other service > > if some params is nit coming in url how to check > > guide me > > -- > Karthik.k > Mobile - +91-9894991640One purpose, one name. Once your code is free from ambiguity, it''ll be easier to help you. -- Posted via http://www.ruby-forum.com/.
2009/8/26 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> hi guys > > i am checking with params[:a].nil? and params[:a].blank? > > but in the url a is not coming but for some other purpose service i am using > the same a for some other service > > if some params is nit coming in url how to check >I don''t understand the question. If a is not in the url then params[:a] will be nil as you say. Please explain more in what way this does not work for you. Colin
Colin Law wrote:> I don''t understand the question. If a is not in the url then > params[:a] will be nil as you say. Please explain more in what way > this does not work for you. > > Colin"I am checking with params[:VARNAME].nil? and params[:VARNAME].blank?. My problem is that I use a variable VARNAME for some other purpose as well. How can I tell?" I mean, you COULD check the format of the VARNAME, but if it''s two similar hashes, you''re out of luck anyway. Best to rename one of them so there''s no ambiguity, and then the problem goes away. -- Posted via http://www.ruby-forum.com/.
2009/8/26 Aldric Giacomoni <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Colin Law wrote: >> I don''t understand the question. If a is not in the url then >> params[:a] will be nil as you say. Please explain more in what way >> this does not work for you. >> >> Colin > > "I am checking with params[:VARNAME].nil? and params[:VARNAME].blank?. > My problem is that I use a variable VARNAME for some other purpose as > well. How can I tell?"It does not matter if you have a variable called varname (don''t use VARNAME, upper case implies a constant in ruby). params[:varname] checks whether the params hash contains an entry for the key varname and is not affected by any variable called varname.> > I mean, you COULD check the format of the VARNAME, but if it''s two > similar hashes, you''re out of luck anyway. Best to rename one of them so > there''s no ambiguity, and then the problem goes away. > -- > Posted via http://www.ruby-forum.com/. >
Colin Law wrote:> It does not matter if you have a variable called varname (don''t use > VARNAME, upper case implies a constant in ruby). params[:varname] > checks whether the params hash contains an entry for the key varname > and is not affected by any variable called varname.Okay, sorry. I was worried about being english-readable and I became ruby-unreadable. I -think- he is saying that he has: params[:varname] ... And params[:varname] may exist for some other purpose but not the purpose he needs, so he wants to make sure it''s the params[:varname] he wants. Does that make sense? Yeah, it doesn''t make sense to me either. That''s why I suggested only passing parameters with unique names. -- Posted via http://www.ruby-forum.com/.