human_urls 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78c8547a4709321f42d08ca58e206b9385067418
4
- data.tar.gz: afc4a16b7d978d446c7e108220644cba1261cba1
3
+ metadata.gz: 5393bf6e06e5d75987dc88493e2a150057ad7c9b
4
+ data.tar.gz: aba57ca33016b5bff8dc705bfafb41f23938c82f
5
5
  SHA512:
6
- metadata.gz: ca416f5d6507769e98b36047abbadcca7d0316c5cd1648e0622ba97f321f4d7031a0f62fed47b6643bd6fab3b250fc039f3c66b54b9da7db4fe8da6164d978a4
7
- data.tar.gz: 7f6af73b354e2503f4899107edfb102c486e3d4ed6ac5028c235a1b04abe6180ca4758d29de7a6bf701867956f00f34a8b1723cef2f2ed69239b102d498a6071
6
+ metadata.gz: 5023ecd3f1a7ff47ff3effd27b10dd7ca8be7264ef0e4fdc24d2d2a0e242e6cbd899010fae9e7ccc408ac2b000bdf3e3287e057c0966367b86d6ba3396322d7e
7
+ data.tar.gz: 24e616c1e2dc026d5a56242845303b9ab35e1caf5c1a73823ac6bd84eb81652cd33b9897da86387420d1a1cc87d8ac7742a280cce8403fceb997728b49928701
@@ -1,6 +1,7 @@
1
1
  module HumanUrls
2
2
  module Sluggable
3
3
  extend ActiveSupport::Concern
4
+ include ActiveModel::Dirty
4
5
 
5
6
  included do
6
7
  before_validation :prepare_slug
@@ -17,7 +18,11 @@ module HumanUrls
17
18
  end
18
19
 
19
20
  define_method(:prepare_slug) do
20
- if generated_from.present?
21
+ # If these conditions generate slug from auto generated field
22
+ if generated_from.present? &&
23
+ (!self.send("#{slug_param}_changed?") ||
24
+ self.send("#{slug_param}").blank?)
25
+ # slug equals autogenerated field
21
26
  self.send("#{slug_param}=", send(generated_from))
22
27
  end
23
28
  self.send("#{slug_param}=", send(slug_param).to_s)
@@ -1,3 +1,3 @@
1
1
  module HumanUrls
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end