roar-rails
roar-rails copied to clipboard
uninitialized constant Tipax::ClientApi::DataSyncRepresenter
Hi, I have a representer in a rails engine with the following code:
module Tipax::ClientApi
module GeoLocationRepresenter
include Roar::JSON
property :title
end
end
and the controller that use representer :
require_dependency "tipax/application_controller"
require "#{Rails.root}/engines/client_api/app/representers/tipax/client_api/geo_location_representer"
module Tipax::ClientApi
class DataSyncController < ApplicationController
include Roar::Rails::ControllerAdditions
respond_to :json
# include Roar::Rails::ControllerAdditions::Render
# represents :json, :entity => Tipax::ClientApi::GeoLocationRepresenter
def get_all_data
geo_locations = Tipax::GeoLocation.all
respond_with geo_locations
end
end
end
when loading action of controller this error raised.
NameError (uninitialized constant Tipax::ClientApi::DataSyncRepresenter):
activesupport (4.2.4) lib/active_support/inflector/methods.rb:263:in const_get' activesupport (4.2.4) lib/active_support/inflector/methods.rb:263:inblock in constantize'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:259:in each' activesupport (4.2.4) lib/active_support/inflector/methods.rb:259:ininject'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:259:in constantize' activesupport (4.2.4) lib/active_support/core_ext/string/inflections.rb:66:inconstantize'
roar-rails (1.0.1) lib/roar/rails/formats.rb:55:in infer_representer' roar-rails (1.0.1) lib/roar/rails/formats.rb:41:incollection_representer'
roar-rails (1.0.1) lib/roar/rails/formats.rb:34:in name_for' roar-rails (1.0.1) lib/roar/rails/formats.rb:18:infor'
roar-rails (1.0.1) lib/roar/rails/controller_additions.rb:47:in representer_for' roar-rails (1.0.1) lib/roar/rails/controller_additions.rb:41:inprepare_model_for'
roar-rails (1.0.1) lib/roar/rails/responder.rb:55:in prepare_model_for' roar-rails (1.0.1) lib/roar/rails/responder.rb:8:indisplay'
responders (2.1.0) lib/action_controller/responder.rb:212:in api_behavior' responders (2.1.0) lib/action_controller/responder.rb:191:inrescue in to_format'
responders (2.1.0) lib/action_controller/responder.rb:185:in to_format' responders (2.1.0) lib/action_controller/responder.rb:163:inrespond'
responders (2.1.0) lib/action_controller/responder.rb:156:in call' responders (2.1.0) lib/action_controller/respond_with.rb:203:inrespond_with'
engines/client_api/app/controllers/tipax/client_api/data_sync_controller.rb:13:in get_all_data' actionpack (4.2.4) lib/action_controller/metal/implicit_render.rb:4:insend_action'
actionpack (4.2.4) lib/abstract_controller/base.rb:198:in process_action' actionpack (4.2.4) lib/action_controller/metal/rendering.rb:10:inprocess_action'
actionpack (4.2.4) lib/abstract_controller/callbacks.rb:20:in block in process_action' activesupport (4.2.4) lib/active_support/callbacks.rb:88:inrun_callbacks'
activesupport (4.2.4) lib/active_support/callbacks.rb:778:in _run_process_action_callbacks' activesupport (4.2.4) lib/active_support/callbacks.rb:81:inrun_callbacks'
actionpack (4.2.4) lib/abstract_controller/callbacks.rb:19:in process_action' actionpack (4.2.4) lib/action_controller/metal/rescue.rb:29:inprocess_action'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:32:in block in process_action' activesupport (4.2.4) lib/active_support/notifications.rb:164:inblock in instrument'
activesupport (4.2.4) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (4.2.4) lib/active_support/notifications.rb:164:ininstrument'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:30:in process_action' activerecord (4.2.4) lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
actionpack (4.2.4) lib/abstract_controller/base.rb:137:in process' actionview (4.2.4) lib/action_view/rendering.rb:30:inprocess'
Hi Abolfazl, I'm sorry to tell you that I don't support this gem anymore, as I find everything about the Rails Way is wrong, even this gem is only a fix on a pile of rubbish. Your problem is an autoloading issue with Rails, which is one of the many reasons I want to get away from Rails as soon as possible.
Try to always use require_dependency instead of require and have a look at Trailblazer, which is my successor to Rails and its mess.