Permalink
Browse files

Bug al localizar recursos por nombre (vía Brenes ;)

  • Loading branch information...
1 parent 9644c29 commit 8370ba167ebdf8d6b50b91211d0b8c9f0ec12acd @nando committed Jun 24, 2010
Showing with 3 additions and 3 deletions.
  1. +1 −1 features/support/app/config/environment.rb
  2. +2 −2 lib/mundo_pepino/resources_history.rb
@@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
-#RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
@@ -128,15 +128,15 @@ def recursive_group_search(model, resources)
def detect_first(arr, value, method = nil)
if value.is_a? String
method ||= :name
- arr.detect { |r| r.respond_to?(method) && (r.send(method) =~ /#{value}/i) }
+ arr.detect { |r| r.respond_to?(method) && (r.send(method) =~ /^#{value}$/i) }
elsif value.is_a? Class
method ||= :is_a?
arr.detect { |r| r.respond_to?(method) && r.send(method, value) }
elsif value.is_a? Array
model, val = value # [ class, value ]
name_field = field_for(model)
arr.detect do |r|
- r.respond_to?(:is_a?) && r.is_a?(model) && r.send(name_field) =~ /#{val}/i
+ r.respond_to?(:is_a?) && r.is_a?(model) && r.send(name_field) =~ /^#{val}$/i
end
else
method ||= :id

0 comments on commit 8370ba1

Please sign in to comment.