Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widgets are broken #5

Closed
mainej opened this issue Nov 11, 2014 · 12 comments
Closed

Widgets are broken #5

mainej opened this issue Nov 11, 2014 · 12 comments

Comments

@mainej
Copy link

mainej commented Nov 11, 2014

Sorry, I think this was introduced during the fix of #3...

This line throws a 'No such file or directory' error when I try to render Widgets.

The file structure is:

app/views/foo/edit.html.rb

module Views
  module Foo
    class Edit < Views::Base
      needs :bar

      def content
        widget(Form, bar: bar)
      end
    end
  end
end

app/views/foo/form.rb

module Views
  module Foo
    class Form < Views::Base
      needs :bar

      def content
        text bar.baz
      end
    end
  end
end

The error is:

ActionView::Template::Error:
       No such file or directory @ dir_initialize - .../app/views/foo/edit
     # .../.rvm/gems/ruby-2.1.2/gems/fortitude-0.0.6/lib/fortitude/rails/railtie.rb:154:in `open'
     # .../.rvm/gems/ruby-2.1.2/gems/fortitude-0.0.6/lib/fortitude/rails/railtie.rb:154:in `entries'

It looks like fortitude is interpreting some of the file name (edit) as part of the directory structure.

@mainej
Copy link
Author

mainej commented Nov 11, 2014

Note that the problem goes away if I either a) use the render partial: "form" syntax, or b) fully qualify the widget name widget(Views::Foo::Form, bar: bar). I'm OK living with that, but maybe some documentation would help?

@ageweke
Copy link
Owner

ageweke commented Nov 12, 2014

Whoops — definitely an oversight. Yeah, the triggering case was referring to an autoloaded widget by partially-qualified module path, and I actually never had a test case that did that. Now I do. 😄

(When you write widget(Form, … above, inside Views::Foo::Edit, Rails very first looks for something called Views::Foo::Edit::Form due to namespacing conventions. My code was hence looking for a file named app/views/foo/edit/form.(rb|html.rb) by scanning the directory app/views/foo/edit; it correctly dealt with the case where form.rb didn't exist, but not where app/views/foo/edit didn't. Now it does.)

Let me know if this works for you — if so, I'll cut 0.0.7 based on it.

@mainej
Copy link
Author

mainej commented Nov 12, 2014

It works... mostly. The widget line no longer throws errors. But, if I change and reload the Views::Foo::Edit file too many times, eventually I will get this error:

ActionView::Template::Error (superclass mismatch for class Edit):
    1: module Views
    2:   module Foo
    3:     class Edit < Views::Base

I have seen the 'superclass mismatch' errors before, so this may be a separate issue.

@mainej
Copy link
Author

mainej commented Nov 12, 2014

Oh, and I've been able to avoid the 'superclass mismatch' problem in the past by adding the following line to the top of every view file:

require_dependency 'views/base'

Just tried it, and it seems to work in this case too.

@ageweke
Copy link
Owner

ageweke commented Nov 12, 2014

Hmmm. I'll take a look and see what I can find — I haven't personally run into this problem, but I'll see if I can reproduce it.

If you find a way to reproduce it even semi-reliably, definitely let me know; I am obviously extremely interested in stamping such things out. :)

@ageweke
Copy link
Owner

ageweke commented Nov 12, 2014

I just pushed a branch, ageweke/classloading_debugging, that contains a single fix that I think might help — it adds a require_dependency of the widget file itself into the generated template code. If you continue having issues, you might try this branch and see if it helps at all.

@mainej
Copy link
Author

mainej commented Nov 12, 2014

Hmm, don't see the branch in your repo. Where is it pushed to?

@ageweke
Copy link
Owner

ageweke commented Nov 12, 2014

Oops — sorry about that. Fixed now. :)

@mainej
Copy link
Author

mainej commented Nov 12, 2014

That branch doesn't really change things for me.

I've been able to consistently reproduce the error. Would you prefer that info in a new issue or should I put it here?

@ageweke
Copy link
Owner

ageweke commented Nov 13, 2014

Sorry to hear that! By all means, if you can consistently reproduce it, file a new issue. Your bug report above was excellent in terms of thoroughness — that level of detail should be able to help me figure it out. The output of ruby --version and rails --version would be awesome, too.

@ageweke
Copy link
Owner

ageweke commented Nov 13, 2014

Oh, and BTW, sorry for the delay. I'm quite scrupulous about not working on OSS during my employer's time or while on their property, so during daytime business hours (PST), I'm unlikely to respond.

@mainej
Copy link
Author

mainej commented Nov 13, 2014

Totally understand... and you're fixing things pretty fast anyway. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants