We have a website called viravira.co. Our domain is on dnsimple and server is on heroku. We configured all necessary steps with ssl both on heroku & dnsimple.
When you type any of these 4 urls to url bar it works.
But the problem is, when I search on google as
ActionController::RoutingError (No route matches "https://www.google.com.tr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwiU0JX39YnQAhWJEiwKHSq2BpQQFggcMAA&url=https%3A%2F%2Fwww.viravira.co%2F&usg=AFQjCNFg0D1KFk0WGvYOfUoVzNm19KDBYw&bvm=bv.137132246,d.bGg"):
before_filter :set_locale, :location_action_name
url = Rails.application.routes.recognize_path(request.referrer)
@last_controller = url[:controller]
@last_action = url[:action]
The issue is caused by the following code fragment:
url = Rails.application.routes.recognize_path(request.referrer) @last_controller = url[:controller] @last_action = url[:action]
As far as I remember (and I guess, given that
recognize_path was removed in recent versions of Rails)
recognize_path raises a routing error in case it can't find the path.
You are passing arbitrary strings to the function, but the function only recognizes paths internally described in the router.
request.referrer would return 3 different types of URL:
In all cases except the third one,
recognize_path will raise an error. The error will be caught by the default Rails handler and displayed as 404 (an unrecognized route results in a 404 in production).
I'm not sure what
location_action_name is supposed to do, but as it is implemented now it's very fragile and in most cases it will result into causing 404 responses in your app.