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

error when Rails view renders a partial #1

Open
eostrom opened this issue Jul 6, 2010 · 0 comments
Open

error when Rails view renders a partial #1

eostrom opened this issue Jul 6, 2010 · 0 comments

Comments

@eostrom
Copy link

eostrom commented Jul 6, 2010

First off, I'm running Cucover on a Spree project, and a lot of the code is in an extension (like a plugin), not in RAILS_ROOT/app. I don't think that's an issue, but I thought I should mention it.

I get a lot of this error:

undefined method `filename' for nil:NilClass (ActionView::TemplateError)  
  cucover (0.1.4) lib/cucover/rails.rb:17:in `render'

The line is:

    filename = args[0][:file].filename

This seems to work fine for views and layouts rendered by the controller: args[0][:file] is a Template object that knows exactly what file it's rendering.

The problem is when the view in turn renders a partial. In this case, there's no :file, just :partial, and the value isn't a Template, it's just a string like "shared/footer". In some cases, args[0] isn't a hash at all, it's just a string.

I made Cucover get past this line with the following code:

    source = args[0]
    filename = if source[:file]
                 source[:file].filename
               elsif source[:partial]
                 source[:partial] =~ /[^\/]+$/
                 source[:partial].sub(/[^\/]+$/, "_#{$&}")
               else
                 source
               end

... but I suspect Cucover won't properly detect when files are changed, because it only has a string like "shared/footer" and not the actual path to the file that was rendered.

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

No branches or pull requests

1 participant