In my Rails 4 app I have a number of static pages that should either be indexable by Google or not. I am using a variable indexable for this but there's probably a better way:
class PagesController < ApplicationController
def home
indexable = true
end
def about_us
indexable = true
end
def secret_stuff
indexable = false
end
end
How can I generate an array of all the pages that are indexable?
I tried doing this in a helper but it's not working:
def indexable_pages
array = []
PagesController.instance_methods(false).each do |action|
if action.indexable == true # this won't work of course
array << action
end
end
array
end
Thanks for any help.
GET. What about something akin to whatrake routesdoes? It's not the action that's indexable, it's the path that ends up at that action, of which there could be many.indexable: trueto be supported.routesand "flags". Can you point me to an example?routes.rbfile you can find and process with a utility script, converting them into your map.