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.