bruce.balmer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Aug-24 15:17 UTC
[Rails] using @request.user_agent to determine if someone is using IE
Hello: I''d like to use @request.user_agent to determine if someone is using IE. So I thought the line if @request.user_agent="Microsoft Internet Explorer" would be a bit of programming genius. Sadly, it does not work and the complaint from rails is "no = method for @request.user_agent. Interesting. So I tried @request.user_agent.include("Microsoft") and apparently there is no include method either. I tried to look up user_agent in the docs to find out what it methods it did have and can find nothing on the subject. For 5 Karma points - what is the solution? bruce --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
bruce.balmer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Aug-24 15:31 UTC
[Rails] Re: using @request.user_agent to determine if someone is using IE
I just answered my own question. Not sure why it did not work when I tried it earlier. Here is a solution for others who want to do the same if @request.user_agent.include?("Microsoft") then @browser = ''MSIE'' else @browser = "other" end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris Hall
2006-Aug-24 15:37 UTC
[Rails] Re: using @request.user_agent to determine if someone is using IE
@request.env["HTTP_USER_AGENT"] =~ /Microsoft Internet Explorer/ On 8/24/06, bruce.balmer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <bruce.balmer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello: > > I''d like to use @request.user_agent to determine if someone is using > IE. So I thought the line > > > if @request.user_agent="Microsoft Internet Explorer" would be a bit of > programming genius. Sadly, it does not work and the complaint from > rails is "no = method for @request.user_agent. Interesting. So I tried > @request.user_agent.include("Microsoft") and apparently there is no > include method either. I tried to look up user_agent in the docs to > find out what it methods it did have and can find nothing on the > subject. > > For 5 Karma points - what is the solution? > > bruce > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris Hall
2006-Aug-24 15:44 UTC
[Rails] Re: using @request.user_agent to determine if someone is using IE
actually, that should be @request.env["HTTP_USER_AGENT"] =~ /MSIE/ On 8/24/06, Chris Hall <christopher.k.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> @request.env["HTTP_USER_AGENT"] =~ /Microsoft Internet Explorer/ > > > On 8/24/06, bruce.balmer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <bruce.balmer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hello: > > > > I''d like to use @request.user_agent to determine if someone is using > > IE. So I thought the line > > > > > > if @request.user_agent="Microsoft Internet Explorer" would be a bit of > > programming genius. Sadly, it does not work and the complaint from > > rails is "no = method for @request.user_agent. Interesting. So I tried > > @request.user_agent.include("Microsoft") and apparently there is no > > include method either. I tried to look up user_agent in the docs to > > find out what it methods it did have and can find nothing on the > > subject. > > > > For 5 Karma points - what is the solution? > > > > bruce > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ljredpath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Aug-24 16:52 UTC
[Rails] Re: using @request.user_agent to determine if someone is using IE
Actually it should be request, not @request. @request, @params et. al are deprecated. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
etlund-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Aug-25 17:36 UTC
Re: using @request.user_agent to determine if someone is using IE
Hey, I think, more fundamentally, the reason your fist attempt failed is that you were using the ''assignment'' operator (=) instead of the ''equals'' operator (==). Eric --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---