Pingr is a super-simple gem built for the blogit project.
Add this line to your application's Gemfile:
gem 'pingr'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pingr
From within your app (most likely a controller):
defping_sitemapsPingr::Request.new(my_sitemap_url)# This will ping Google and BingendA good way to do this would be using Rails's after filters:
classPostsController < ActionController::Baseafter_filter:ping_sitemaps,only: [:create,:update,:destroy]# ...privatedefping_sitemapsPingr::Request.new(my_sitemap_url)endendYou can view the supported search engines and add your own by viewing the code in this directory:
https://github.com/Bodacious/pingr/tree/master/lib/pingr/search_engines
By default, Pingr is set to :test mode, meaning it won't actually perform the requests. If the Rails environment is :production then the mode is set to :live which will perform requests to the search engines.
You can change this by manually setting Pingr.mode
# in config/initializers/pingr.rbPingr.mode=:liveifRails.env =~ /staging|production/NOTE: Search engines may penalise or black-list you if you perform too many requests - they recommend no more than one per hour.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request