ArgumentError (malformed format string - %{): #11

Open
qintil opened this Issue Nov 17, 2011 · 6 comments

Comments

Projects
None yet
2 participants

qintil commented Nov 17, 2011

ArgumentError (malformed format string - %{):
/usr/lib/ruby/gems/1.8/gems/simple_autocomplete-0.3.8/lib/simple_autocomplete.rb:14:in %' /usr/lib/ruby/gems/1.8/gems/simple_autocomplete-0.3.8/lib/simple_autocomplete.rb:14:inautocomplete_for_city_name'
/usr/lib/ruby/gems/1.8/gems/simple_autocomplete-0.3.8/lib/simple_autocomplete.rb:14:in map' /usr/lib/ruby/gems/1.8/gems/simple_autocomplete-0.3.8/lib/simple_autocomplete.rb:14:inautocomplete_for_city_name'

I just implemented on my application but always get this error,
My Ruby is 1.8.7 with rails 2.3.14

Owner

grosser commented Nov 17, 2011

Its coming from
https://github.com/grosser/simple_auto_complete/blob/master/lib/simple_autocomplete.rb#L14

so it could be that the :query is the problem or one of the methods. Please paste the line from your code where you call it.

@grosser grosser closed this Nov 17, 2011

@grosser grosser reopened this Nov 17, 2011

qintil commented Nov 17, 2011

I just add

autocomplete_for :city, :name

on my search controller whitout any additional option

and here my view

<%= f.text_field :auto_city_name, :class => 'autocomplete', 'data-autocomplete-url'=>autocomplete_for_city_name_commercial_search_path %>

here my routes.rb

map.namespace :commercial do |commercial|
commercial.resources :properties, :member => {:review => :get,
:activate => :post,
:deactivate => :post,
:sell_pending => :post,
:sell => :post,
:gen_pdf => :get,
:modal_sell => :get,
:repost => :post } do |property|
property.resources :photos, :controller => "listing/photos", :namespace => ""
property.resources :videos, :controller => "listing/videos", :namespace => ""
property.resources :documents, :controller => "listing/documents", :namespace => ""
property.resources :emails, :controller => "listing/emails", :namespace => "", :collection => {:confirm => :get}
property.resources :tags, :controller => "listing/tags", :namespace => ""
property.resources :messages, :controller => "listing/messages", :namespace => ""
property.resources :abuse_reports, :controller => "listing/abuse_reports", :namespace => ""
property.resource :watch, :controller => "listing/watches", :namespace => ""
property.resource :pdf
end

commercial.resources :property_types
commercial.resource  :search, :collection => { :autocomplete_for_city_name => :get}

end

Owner

grosser commented Nov 17, 2011

for some reason you do not have i18n loaded, it provides the % substitution, maybe you are on a very old rails version or somehow disabled it ...
try this in your rails console, simple_auto_complete wont work until this works: "%{a}" % {:a => 1} == "1"

qintil commented Nov 18, 2011

yes, I'am using tuby 1.8.7 and rails 2.3.14, and the console say malformed format string - %{, is it not compatible with that?, because I can't update my rails, its causing error on other part

qintil commented Nov 18, 2011

I think the problem on the ruby version, ruby 1.8.7 does'nt know the code "%{a}" % {:a => 1} == "1", becuase when I try on rails 3 and ruby 1.8.7 an error still come,
but it running well on rails 2 with ruby 1.9.2,
can you make the gem work on ruby 1.8.7 please

Owner

grosser commented Nov 18, 2011

I can think of 3 solutions:

require 'i18n/core_ext/string/interpolate'

or

require 'fast_gettext'

or

curl https://raw.github.com/svenfuchs/i18n/master/lib/i18n/core_ext/string/interpolate.rb > config/initializers/inerpolate.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment