I would like to set a before filter in a rails app as follows:
before_filter :set_instance_variables, :unless => :active_pages?
def active_pages?
params[:controller] == "admin/*"
end
where I would like it to have the * represent any word so that the method is checking against any of the controllers that start with ‘admin/’. I thought the asterisk might be a wild card and work, but it doesn’t seem to be working. How can I accomplish this?
It uses
=~to match a String to a regular expression, and%r{}for the regular expression because your pattern contains a/(the//notation would be harder to read).