GithubHelp home page GithubHelp logo

referer-parser-rails's Introduction

Build Status

Referer::Parser::Rails

It is a referer-parser extension for Rails.

Installation

Add this line to your application's Gemfile:

gem 'referer-parser-rails'

And then execute:

$ bundle

Usage

Then you can use two methods for your ActionDispatch::Request object in application:

# Get a search term from the referer and return it as a string. If the referer is not present then nil returns.
request.search_term

# Get a search engine from the referer and return it as a string. If the referer is not present then nil returns.
request.search_engine

Why being useful?

You have some product in your e-shop, for example, "iPad 2". And your buyers can find the link to this product on google, yandex or any other search engine. And what if Apple Co. has launched "The new Ipad" and now you have no "iPad 2"s in stock in the shop but the link to this product is still alive and people, while browsing the web, can still find it and get 404 error.

If the user comes across this kind of page browsing this or that search engine, he will find the special "404" page. On our website he will get the status "404" and what more find the results of the search according to his search term.

The only thing you need to do is to write in your controller something like this:

if request.search_term.present?
  # find the goods on the website according to the user search term
  @proposals = Search::Manager.new({:query => request.search_term})
end

referer-parser-rails's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.