Project

ads-rails

0.02
No commit activity in last 3 years
No release in over 3 years
Helper to create the google adsense include tag in rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 0.21

Runtime

~> 5.1
 Project Readme

Gem Version Code Climate Build Status Dependency Status

Ads Rails

Helper to create the google adsense include tag in rails.

Why

I did this gem to:

  • Have a simple but versatile way to include google adsense.

Install

Put this line in your Gemfile:

gem 'ads-rails'

Then bundle:

$ bundle

Configuration

Generate the configuration file:

$ bundle exec rails g ads:install

Customize the sample tag if you want:

Ads.configure do |config|

  config.sample_tag do |options|
    style = "width: #{options[:width]}px; height: #{options[:height]}px; background: #c8c8c8;"
    content_tag :div, nil, style: style
  end

end

Usage

In your views call the helper like this:

<%= google_adsense_include_tag client: 'pub-1234', slot: '1234', ... %>

All the arguments will be mapped to the the corresponding google_ad variable:

google_ad_client = 'pub-1234'
google_ad_slot = 1234
.
.
.

NOTE: If environment is not production, the sample tag will be use instead.

Contributing

Any issue, pull request, comment of any kind is more than welcome!

I will mainly ensure compatibility to Rails, AWS, PostgreSQL, Redis, Elasticsearch and FreeBSD. 

Credits

This gem is maintained and funded by mmontossi.

License

It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.