Is there a way to do an if/else case to check the URL? for example- <% if URL = "http://www.google.com" %> Hi, your URL''s GOOGLE <% else %> You URL isn''t GOOGLE <% end %> Of course that method is just a mockup, does anyone know the real syntax? Thanks -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On May 20, 2010, at 3:05 PM, David Zhu wrote:> Is there a way to do an if/else case to check the URL? for example- > > <% if URL = "http://www.google.com" %> > > Hi, your URL''s GOOGLE > > <% else %> > > You URL isn''t GOOGLE > > <% end %> > > Of course that method is just a mockup, does anyone know the real > syntax? Thanks<% if request.url == ''http://www.google.com'' %> GOOGLE! <% else %> not google <% end %> That''s literally what you''re asking, but not sure if it''s really what you want to do. You might be better off checking params[:controller] and params[:action] perhaps. Or doing a regular expression match to pick up "http://google.com" and "http://maps.google.com/q=12345+Maple+St", etc. But... in any event, request.url will give you what the browser sees in their location bar. -philip -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On May 20, 6:12 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> On May 20, 2010, at 3:05 PM, David Zhu wrote: > > > Is there a way to do an if/else case to check the URL? for example- > > > <% if URL = "http://www.google.com" %> > > > Hi, your URL''s GOOGLE > > > <% else %> > > > You URL isn''t GOOGLE > > > <% end %> > > > Of course that method is just a mockup, does anyone know the real > > syntax? Thanks > > <% if request.url == ''http://www.google.com''%> > GOOGLE! > <% else %> > not google > <% end %> > > That''s literally what you''re asking, but not sure if it''s really what you want to do. You might be better off checking params[:controller] and params[:action] perhaps. Or doing a regular expression match to pick up "http://google.com" and "http://maps.google.com/q=12345+Maple+St", etc. > > But... in any event, request.url will give you what the browser sees in their location bar. > > -philipYUP! sweet dude, thanks :D> > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.