Permalink
Browse files

Stricter @regex matcher

The purpose of this regex is to match prefix + method + suffix. By using + instead of * we ensure that we only match strings where method is not blank.
  • Loading branch information...
1 parent fff3e75 commit 262981d0c46f5878358cf07448c1cd809df2d8b9 @oscardelben committed Apr 2, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 activemodel/lib/active_model/attribute_methods.rb
@@ -325,7 +325,7 @@ def initialize(options = {})
end
@prefix, @suffix = options[:prefix] || '', options[:suffix] || ''
- @regex = /^(?:#{Regexp.escape(@prefix)})(.*)(?:#{Regexp.escape(@suffix)})$/
+ @regex = /^(?:#{Regexp.escape(@prefix)})(.+)(?:#{Regexp.escape(@suffix)})$/
@method_missing_target = "#{@prefix}attribute#{@suffix}"
@method_name = "#{prefix}%s#{suffix}"
end

0 comments on commit 262981d

Please sign in to comment.