Helper to create the google adsense include tag in rails.
I did this gem to:
- Have a simple but versatile way to include google adsense.
Put this line in your Gemfile:
gem 'ads-rails'
Then bundle:
$ bundle
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
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.
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.
This gem is maintained and funded by mmontossi.
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.