|
89 | 89 |
|
90 | 90 | helper_method :extract_controller_action_name do |hash_node|
|
91 | 91 | controller_name = hash_node.controller_value.to_value
|
92 |
| - action_name = hash_node.action_value.to_value |
| 92 | + action_name = hash_node.action_value&.to_value || 'index' |
93 | 93 | "#{controller_name}##{action_name}"
|
94 | 94 | end
|
95 | 95 |
|
|
179 | 179 | with_node node_type: 'call_node', name: 'with_options', block: { node_type: 'block_node' } do
|
180 | 180 | new_routes = []
|
181 | 181 | node.block.body.body.each do |child_node|
|
| 182 | + next if child_node.arguments.nil? |
| 183 | + |
182 | 184 | url = child_node.arguments.arguments.first.to_value
|
183 | 185 | hash_node = child_node.arguments.arguments.last
|
184 | 186 | if hash_node.action_value || url !~ /:action/
|
|
217 | 219 | name: { in: ['resource', 'resources'] },
|
218 | 220 | arguments: { node_type: 'arguments_node', arguments: { size: 2, last: { node_type: 'keyword_hash_node' } } } do
|
219 | 221 | hash_argument = node.arguments.arguments.last
|
220 |
| - new_routes = '' |
| 222 | + new_routes = [] |
221 | 223 | if !hash_argument.collection_value.nil? || !hash_argument.member_value.nil?
|
222 | 224 | collection_routes = hash_argument.collection_value
|
223 | 225 | member_routes = hash_argument.member_value
|
224 | 226 | other_options_code = reject_keys_from_hash(hash_argument, :collection, :member)
|
225 |
| - new_routes = [] |
226 |
| - new_routes << if other_options_code.length > 0 |
227 |
| - "{{message}} {{arguments.arguments.first}}, #{other_options_code} do\n" |
228 |
| - else |
229 |
| - "{{message}} {{arguments.arguments.first}} do\n" |
230 |
| - end |
| 227 | + if other_options_code.length > 0 |
| 228 | + new_routes << "{{message}} {{arguments.arguments.first}}, #{other_options_code} do\n" |
| 229 | + else |
| 230 | + new_routes << "{{message}} {{arguments.arguments.first}} do\n" |
| 231 | + end |
231 | 232 | new_routes << generate_new_collection_routes(collection_routes) if collection_routes
|
232 | 233 | new_routes << generate_new_member_routes(member_routes) if member_routes
|
233 | 234 | else
|
|
0 commit comments