Update exhibit.rb #36

Merged
merged 3 commits into from Apr 4, 2013

2 participants

@amaierhofer

Checking for class name before downcasing. 

classes returned from view_context call in controller are anonymous and respond with nil when asked for their name.

Or is there any reason why I should not be passing view_context objects?

@amaierhofer amaierhofer Update exhibit.rb
Checking for class name before downcasing. 

classes returned from <code>view_context</code> call in controller are anonymous and respond with nil when asked for their name.
bc2d58a
@codeodor
Objects on Rails member

I'd like to understand better what's going on when this happens. For instance, when does object.class.name return nil?

Can you get it to happen in a failing test (that fails before the modification)?

@codeodor
Objects on Rails member

The reason I'd like to see it is because I have a feeling something is going on that needs to be fixed to where we don't get classes with nil names, as opposed to just checking for nil.

@amaierhofer

Yes, that would definitely be better, but I don't see how this can be done, maybe I need to change my code here.

I am passing what is returned from #view_context (https://github.com/rails/rails/blob/1eb6189404f53ae59e4cb47ef9d5ad3a9bec3064/actionpack/lib/abstract_controller/rendering.rb#L75) to the exhibit call in the controller. In my case the object returned is an instance of an anonymous class. The reason I am doing this is because it gives me access to view helpers my exhibits.

@codeodor
Objects on Rails member

Oh, of course! Sorry I missed that when you mentioned it before, and thanks for pointing it out.

I hadn't considered someone might be using anonymous classes.

Let me see if I can write a test for it and then I'll merge.

@amaierhofer amaierhofer Merge pull request #1 from codeodor/patch-1
Add test that ensures .exhibit works when passed a context that is an instance of an anonymous class
974ff0e
@codeodor codeodor merged commit 8bd5bfb into objects-on-rails:master Apr 4, 2013

1 check passed

Details default The Travis build passed
@codeodor
Objects on Rails member

Thanks @amaierhofer!

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