Module: ActionDispatch::Routing::Mapper::Resources
- Defined in:
- lib/active_scaffold/extensions/routing_mapper.rb
Instance Method Summary collapse
- #as_association_routes ⇒ Object
- #as_nested_resources(*resources) ⇒ Object
- #as_routes(opts = {association: true}) ⇒ Object
- #as_scoped_routes(*scopes) ⇒ Object
- #define_active_scaffold_association_concern ⇒ Object
- #define_active_scaffold_concern ⇒ Object
- #parent_options ⇒ Object
- #parent_scaffold ⇒ Object
Instance Method Details
#as_association_routes ⇒ Object
110 111 112 113 114 |
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 110 def as_association_routes define_active_scaffold_association_concern unless @concerns[:active_scaffold_association] ActiveSupport::Deprecation.warn 'Use concerns: :active_scaffold_association in resources instead of as_association_routes, or concerns :active_scaffold_association in resources block if want to restrict routes with only or except options.' concerns :active_scaffold_association, end |
#as_nested_resources(*resources) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 116 def as_nested_resources(*resources) = resources. = .merge(parent_scaffold: parent_scaffold) resources.each do |resource| resources(resource, .merge(association: resource)) { yield if block_given? } end end |
#as_routes(opts = {association: true}) ⇒ Object
101 102 103 104 105 106 107 108 |
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 101 def as_routes(opts = {association: true}) define_active_scaffold_concern unless @concerns[:active_scaffold] if opts[:association] && !@concerns[:active_scaffold_association] define_active_scaffold_association_concern end ActiveSupport::Deprecation.warn 'Use concerns: :active_scaffold in resources instead of as_routes, or concerns :active_scaffold in resources block if want to disable association routes or restrict routes with only or except options.' concerns :active_scaffold, .merge(association: opts[:association]) end |
#as_scoped_routes(*scopes) ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 124 def as_scoped_routes(*scopes) = scopes. = .merge(parent_scaffold: parent_scaffold, association: parent_resource.plural) scopes.each do |scope| resources(scope, .merge(named_scope: scope)) { yield if block_given? } end end |
#define_active_scaffold_association_concern ⇒ Object
96 97 98 99 |
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 96 def define_active_scaffold_association_concern ActiveSupport::Deprecation.warn 'Add concern :active_scaffold_association, ActiveScaffold::Routing::Association.new to your routes file.' concern :active_scaffold_association, ActiveScaffold::Routing::Association.new end |
#define_active_scaffold_concern ⇒ Object
91 92 93 94 |
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 91 def define_active_scaffold_concern ActiveSupport::Deprecation.warn 'Add concern :active_scaffold, ActiveScaffold::Routing::Basic.new(association: true) to your routes file.' concern :active_scaffold, ActiveScaffold::Routing::Basic.new(association: true) end |
#parent_options ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 80 def opts = parent_resource.instance_variable_get(:@options) if Rails.version >= '5.0.0' opts.merge( only: parent_resource.instance_variable_get(:@only), except: parent_resource.instance_variable_get(:@except) ) end opts end |
#parent_scaffold ⇒ Object
132 133 134 |
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 132 def parent_scaffold merge_module_scope(@scope[:module], parent_resource.plural) end |