ruby on rails - Rails3 URI() if condition not working -


class applicationcontroller < actioncontroller::base   before_filter :store_ref_url    def store_ref_url     rf = request.referer     if ((uri(rf.to_s).host != "dev-beta.foo.com") && (uri(rf.to_s).host != "beta.foo.com") && uri(rf.to_s).port != "3000")       session['referer'] = request.referer     end   end end 

if domain "dev-beta.foo.com" or "beta.foo.com" or port 3000 in local machine, dont save request.referer in session['referer']. still keeps on saving it. tried several conditions. doing wrong?

a couple of suggestions:

it looks you're trying determine when you're running in staging or development vs production, in case can use:

rails.env.production? 

to information. can set staging environment deploy on dev-beta.foo.com site, use rails.env.staging? same way.

to debug specific question asked, find out request.referer variable on request failing test, open console , test logic conditions 1 @ time , see conditions failing.

finally, personal preference see logic conditions placed on before filter itself, may not universal sentiment.

edit might add last condition != "3000" not doing anything; don't think port method returns string...


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -