Remote_table in spree 0.70.7 controller: #<TypeError: Zip is not a module>
bsa7 opened this issue · 4 comments
Hi!
I'm include gem 'remote_table' in my Gemfile (Rails 3.1.12)
In spree admin i'd create new controller:
class Admin::XlsPriceLoadsController < Admin::BaseController
def upload
source_xls = RemoteTable.new(filename)
source_xls.each do |row|
....
end
end
end
but when this action fired, i'm see the next:
TypeError (Zip is not a module):
app/controllers/admin/xls_price_loads_controller.rb:26:in `upload'
...
when i'm explore the source_xls object, a frozen?
property of them is true.
So, can any soul write me, why the parsed object is frozed?
And, if i run this code
source_xls = RemoteTable.new(filename)
source_xls.each do |row|
....
end
from lib/tasks as rake task - all work fine!
All wo
Thanks for all advice!
hi @r72cccp !
TypeError (Zip is not a module):
app/controllers/admin/xls_price_loads_controller.rb:26:in `upload'
what is the whole error message? thanks!
All error message is:
Completed 500 Internal Server Error in 464ms
TypeError (Zip is not a module):
app/helpers/prices_helper.rb:25:in `xls_read'
app/controllers/admin/xls_price_loads_controller.rb:26:in `upload'
app/middlewares/empty_session_cookie_cleaner.rb:12:in `call'
app/middlewares/accept_header_corrector.rb:9:in `call'
app/middlewares/redirect_old_product_url.rb:13:in `call'
config/initializers/clean_cookies.rb:51:in `call'
config/initializers/sanitize_env.rb:19:in `call'
Rendered /home/slon/.rvm/gems/ruby-2.1.1/gems/actionpack-3.1.12/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms)
Rendered /home/slon/.rvm/gems/ruby-2.1.1/gems/actionpack-3.1.12/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
Rendered /home/slon/.rvm/gems/ruby-2.1.1/gems/actionpack-3.1.12/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (3.7ms)
grep -R Zip .
And i get:
./models/zip.rb:class Zip < ActiveRecord::Base
./helpers/admin/zips_helper.rb:module Admin::ZipsHelper
./controllers/admin/zips_controller.rb:class Admin::ZipsController < Admin::ResourceController
So, if i'm understand right - the module Zip in somewhere which used my remote_table was oberrided with class Zip in models/zip.rb. So, what ca i do? Rename class Zip in model and their descendands?
P.S.
I overwrited class in model from Zip to ZipCode and ... tadam!!!
All work fine
Thanks!!!