aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorrono23 <rono23@gmail.com>2013-12-19 01:35:30 +0900
committerrono23 <rono23@gmail.com>2013-12-19 05:29:16 +0900
commitee738f960439e511285bc53b7207cebacda8db36 (patch)
treedc0ebecdfcb6258e0c4e2896f5407d1610018af3 /activerecord/lib
parent7b5cf7ef9dce90dc5352a0f220e65722fe44a962 (diff)
downloadrails-ee738f960439e511285bc53b7207cebacda8db36.tar.gz
rails-ee738f960439e511285bc53b7207cebacda8db36.tar.bz2
rails-ee738f960439e511285bc53b7207cebacda8db36.zip
Fix to_param when attribute has multibyte character
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/integration.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/integration.rb b/activerecord/lib/active_record/integration.rb
index 27576b1e61..31e2518540 100644
--- a/activerecord/lib/active_record/integration.rb
+++ b/activerecord/lib/active_record/integration.rb
@@ -98,8 +98,10 @@ module ActiveRecord
super()
else
define_method :to_param do
- if (default = super()) && (result = send(method_name).to_s).present?
- "#{default}-#{result.squish.truncate(20, separator: /\s/, omission: nil).parameterize}"
+ if (default = super()) &&
+ (result = send(method_name).to_s).present? &&
+ (param = result.squish.truncate(20, separator: /\s/, omission: nil).parameterize).present?
+ "#{default}-#{param}"
else
default
end