# Default JS controller for all actions in current Rails controller # Set a new value or get current value def self.js_controller(new_value = nil) @js_controller = new_value || @js_controller || self.name.sub(/Controller$/, '').gsub(/::/, /-/) end # Lets each action customize it attr_writer :js_controller # If action does not set a value, use controller default value def js_controller @js_controller || self.class.js_controller end helper_method :js_controller