Reputation: 3
I want to generate a sitemap of a website with more than 300 URL path. Therefore using a sitemap generator, I am fetching URL path from routes.rb file. Now I don't want SEO to crawl through my post url. So, I wanted to determine the Http-method type of controller paths in sitemap.rb. How to do that?
I have tried to fetch http-method with route.path.spec.left.memo.request_method_match, but NoMethodError occue.
Upvotes: 0
Views: 153
Reputation: 325
Request method is also called verb
, so you can do following:
Rails.application.routes.routes.collect do |route|
"#{route.name} = #{route.defaults} = #{route.verb}"
end
Different version of rails might have it slightly different, but once you have your route look for verb
. (check documentation: https://www.rubydoc.info/docs/rails/4.1.7/ActionDispatch/Journey/Route)
I think this gives you enough info to continue.
Upvotes: 2