avo 1.14.0 → 1.15.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of avo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 629b21141b1ec354e7438f5e18cc8c5da295d255efecf5ecbdd8a01ab49bae69
4
- data.tar.gz: 0dcf8a16ea1875213f781205ce06ef960b6cedf0eb1db2a18c1aa1725de42980
3
+ metadata.gz: d383ac646109d2df17ad55051991565b86751396b90f07bed6febd2c74ec2a3b
4
+ data.tar.gz: 165d98536e64218b88b4cd4e3191cabf1ccda0469d3bd85d84d1498097c1404f
5
5
  SHA512:
6
- metadata.gz: aafa9e05b6298fef31a0501a9904a81f91227f6a5c55929a606072ac627936fedb884207d613fd073d760f4e21669c88ba8f3606644629cbb20b12a500d95334
7
- data.tar.gz: 70c2ad426664105c49ee2c83211c0778126f4f36e8e8bcb93aecc3295bd585f3b25cc248d03d0a8a9c0ed3b450748cae223facc909e79e908e871569e7b49f86
6
+ metadata.gz: d3981465a470c93bef51cea94d4fe2b1cd3473e0e07bcbd5e7bdd2dcc7749d14ad9560fe2b46794e8e41a4554725cefaab61b68908ede56d3f6cf1bda54d42b7
7
+ data.tar.gz: c96ee899de497fa540760abab565bbca84b4d40b074159e73403661604fefffa3bca342bbf8407c07a27bbaad0c95d3c2cf5f1dccd4f72376b3ce73a508d7c5f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (1.14.0)
4
+ avo (1.15.0.pre.1)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -97,9 +97,9 @@ module Avo
97
97
  end
98
98
 
99
99
  def resource_path(model = nil, resource_id: nil, keep_query_params: false, **args)
100
- return avo.send :"resources_#{model.model_name.route_key.singularize}_path", resource_id, **args if resource_id.present?
100
+ return avo.send :"resources_#{singular_name(model)}_path", resource_id, **args if resource_id.present?
101
101
 
102
- avo.send :"resources_#{model.model_name.route_key.singularize}_path", model, **args
102
+ avo.send :"resources_#{singular_name(model)}_path", model, **args
103
103
  end
104
104
 
105
105
  def resource_attach_path(model_name, model_id, related_name, related_id = nil)
@@ -119,11 +119,11 @@ module Avo
119
119
  end
120
120
 
121
121
  def new_resource_path(model, **args)
122
- avo.send :"new_resources_#{model.model_name.route_key.singularize}_path", **args
122
+ avo.send :"new_resources_#{singular_name(model)}_path", **args
123
123
  end
124
124
 
125
125
  def edit_resource_path(model, **args)
126
- avo.send :"edit_resources_#{model.model_name.route_key.singularize}_path", model, **args
126
+ avo.send :"edit_resources_#{singular_name(model)}_path", model.id, **args
127
127
  end
128
128
 
129
129
  private
@@ -283,5 +283,23 @@ module Avo
283
283
  def on_api_path
284
284
  request.original_url.match?(/.*#{Avo::App.root_path}\/avo_api\/.*/)
285
285
  end
286
+
287
+ def get_model_class(model)
288
+ if model.instance_of?(Class)
289
+ model
290
+ else
291
+ model.class
292
+ end
293
+ end
294
+
295
+ def singular_name(model_or_class)
296
+ model_class = get_model_class model_or_class
297
+
298
+ if ActiveModel::Naming.uncountable? model_class
299
+ model_class.model_name.route_key.singularize.gsub('_index', '')
300
+ else
301
+ model_class.model_name.route_key.singularize
302
+ end
303
+ end
286
304
  end
287
305
  end
@@ -161,7 +161,7 @@ module Avo
161
161
  private
162
162
 
163
163
  def model_route_key
164
- @resource.model_class.model_name.route_key.singularize
164
+ singular_name @resource.model_class
165
165
  end
166
166
 
167
167
  def model_params
data/lib/avo/app.rb CHANGED
@@ -169,6 +169,8 @@ module Avo
169
169
  resource.to_s.underscore.gsub("_resource", "").downcase.pluralize.to_sym
170
170
  end
171
171
 
172
+ # Handle uncountable routes
173
+ route_key = route_key.to_sym
172
174
  resources route_key
173
175
  end
174
176
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "1.14.0"
2
+ VERSION = "1.15.0.pre.1"
3
3
  end