Skip to content

Commit

Permalink
Do not raise a nomethoderror if :url is given but the polymorphic pat…
Browse files Browse the repository at this point in the history
…h of the model does not exist.
  • Loading branch information
slainer68 committed Jul 21, 2010
1 parent fd4577b commit e80eb5c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/scoped_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ def form_for(record, *args, &block)
if record.is_a?(ScopedSearch::Base)
options = args.extract_options!
options.symbolize_keys!

options.reverse_merge!({ :url => polymorphic_path(record.model_class), :as => :search })

default_model_route = (polymorphic_path(record.model_class) rescue nil)

options.reverse_merge!({ :url => default_model_route, :as => :search })
raise "You have to manually specify :url in your form_for options..." unless options[:url].present?

options[:html] ||= {}
options[:html].reverse_merge!({ :method => :get })
args << options
Expand Down

0 comments on commit e80eb5c

Please sign in to comment.