How to generate an array of controller actions in Ruby on Rails? -
in rails 4 app have number of static pages should either indexable google or not. using variable indexable there's improve way:
class pagescontroller < applicationcontroller def home indexable = true end def about_us indexable = true end def secret_stuff indexable = false end end how can generate array of pages indexable?
i tried doing in helper it's not working:
def indexable_pages array = [] pagescontroller.instance_methods(false).each |action| if action.indexable == true # won't work of course of study array << action end end array end thanks help.
maybe before_filter create sense?
class pagescontroller < applicationcontroller before_filter :set_indexable, except: [:secret_stuff] def home end def about_us end def secret_stuff end private def set_indexable @indexable = true end end ruby-on-rails ruby
No comments:
Post a Comment