2013-06-16 14 views
6

Uaktualniłem do rails4 z 3.2.2 i teraz otrzymałem tę niezdefiniowaną metodę z mojego szablonu rabl, którego identyfikator nie dostał przed aktualizacją. Parametr "ząb" w procedurach jest zbiorem za pomocą metody pobierającej/ustawiającej, która jest przechowywana w bazie danych PostgreSQL jako hstore hash o nazwie properties. Nie jestem pewien, co zmieniło się w rails4, aby tak się stało! Każda pomoc byłaby mile widziana.Nieokreślona metoda "skanowanie" dla {"ząb" => ""}: Hash

BŁĄD:

Showing /home/action/app/views/procedures/chart.json.rabl where line #1 raised: 

undefined method `scan' for {"tooth"=>""}:Hash 
Extracted source (around line #1): 
1 object @procedures 
2 attributes :buccal, :mesial, :occlusal, :distal, :lingual 

Trace of template inclusion: app/views/procedures/_procedures_table.html.erb, app/views/procedures/chart.html.erb 

Procedury modelu (getter i setter dla: ząb)

%w[tooth buccal mesial occlusal distal lingual].each do |key| 
    attr_accessible key 
    scope "has_#{key}", lambda { |value| where("properties @> (? => ?)", key, value) } 

    define_method(key) do 
     properties && properties[key] 
    end 

    define_method("#{key}=") do |value| 
     self.properties = (properties || {}).merge(key => value) 
    end 
end 

Gemfile:

source 'http://rubygems.org' 

gem 'rails', '4.0.0.rc2' 

# Bundle edge Rails instead: 
# gem 'rails',  :git => 'git://github.com/rails/rails.git' 

gem 'pg' 
gem "paperclip", "~> 3.0" 
gem 'rabl' 
gem 'activerecord-postgres-hstore' 
gem "bugsnag" 
gem 'country_select' 

gem 'bullet', group: :development 

# Asset template engines 
gem 'sass-rails', '~> 4.0.0.rc1' 
gem 'coffee-rails', '~> 4.0.0.rc1' 
gem 'uglifier', '>= 1.3.0' 
gem 'twitter-bootstrap-rails' 
gem 'therubyracer', :platform => :ruby 
gem 'less-rails' 
gem 'jquery-ui-rails' 

gem 'jquery-rails' 

# Use unicorn as the web server 
# gem 'unicorn' 

# Deploy with Capistrano 
# gem 'capistrano' 

# To use debugger 
# gem 'ruby-debug19', :require => 'ruby-debug' 


# Declarative Authorization 
gem 'declarative_authorization' 
gem 'protected_attributes' 

# Authlogic 
gem 'authlogic' 

gem 'simple_form', '3.0.0.rc' 

group :production do 

end 

group :test do 
    # Pretty printed test output 
    gem 'turn', :require => false 
end 
gem 'rubber' 
gem 'open4' 
gem 'gelf' 
gem 'graylog2_exceptions', :git => 'git://github.com/wr0ngway/graylog2_exceptions.git' 
gem 'graylog2-resque' 
+0

Znaleziono odpowiedź !! Rails 4 ma teraz natywne wsparcie dla Hstore, co jest niesamowite, ale nie zdawałem sobie z tego sprawy. Aby naprawić mój problem, po prostu postępowałem zgodnie z tym przewodnikiem poniżej, który jest świetny do skonfigurowania mojego modelu z hstore, a następnie usunął moje metody getter/setter. http://blog.remarkablelabs.com/2012/12/a-love-affair-w-postgresql-rails-4-countdown-to-2013 – mattclar

+0

Na wszelki wypadek przenoszę swoją aplikację do Rails 4 Rc2 i miałem ten sam problem związany ze "skanowaniem", ale musiałem tylko usunąć metodę serializacji z modelu :-). serializacja: dane, ActiveRecord :: Kodery :: Hstore – joselo

Odpowiedz

Powiązane problemy