Felipe Elias

Results 13 comments of Felipe Elias

Maybe I didn't fully comprehend the question, but if you have a namespaced class, it will attempt to get the namespaced presenter, check out the [code here](https://github.com/felipeelias/resubject/blob/master/spec/resubject/naming_spec.rb#L27) Maybe there are...

Ok now I see your problem. I will create a test case for that and check what's happening. Thanks!

I'm just guessing, but are you presenting something like this? ``` ruby class Namespace::Controller def index present Model.new # which points to Namespace::Model end end ```

Try this: ``` ruby class BoxController < ActionController::Base require_dependency 'app/presenters/fancy/box_presenter' def index @box = present Box.new @fancy_box = present Fancy::Box.new Rails.logger.info @box.class.name Rails.logger.info @fancy_box.class.name end end ```

This is clearly an autoload issue. Basically on [`Naming`](https://github.com/felipeelias/resubject/blob/master/lib/resubject/naming.rb#L29) class, if we replace: ``` presenter.split('::').inject(Object) { |ns, cons| ns.const_get(cons) } ``` with ``` presenter.constantize ``` It works. The problem is...

It's not a bug in Rails, it's just how it works - if you have this exact situation - and you have to rely on `require_dependency`. However there's a fix...

wow, nice finding! I just tested and you're right, it fixes this scenario with rails autoload. I couldn't write a failing test to justify this thought... Unless I require ActiveSupport...

Just checked and @terlar is right ``` ruby U = Struct.new(:a) U.ancestors => [U, Struct, Enumerable, Object, PP::ObjectMixin, Kernel, BasicObject] ```

Also, there are few other workarounds ``` ruby ThePresenter.new(Struct.new(...), view_context) # if in a controller # when array ThePresenter.all([Struct, Struct], view_context) ``` The other way would check if the class...

@drewda I'm not maintaining this project anymore. Feel free to add it :smile: