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

no implicit conversion of nil into String #19

Open
firedev opened this issue Apr 12, 2015 · 7 comments
Open

no implicit conversion of nil into String #19

firedev opened this issue Apr 12, 2015 · 7 comments

Comments

@firedev
Copy link

firedev commented Apr 12, 2015

Just tried to use nestive with Rails 4.2, here is a sample admin.html.erb:

<%=  extends :application do %>
  <% purge :menus %>
<% end %>

It blows up with

TypeError - no implicit conversion of nil into String:
  nestive (0.6.0) lib/nestive/layout_helper.rb:92:in `extends'
@firedev firedev closed this as completed Apr 12, 2015
@firedev firedev reopened this Apr 12, 2015
@firedev
Copy link
Author

firedev commented Apr 12, 2015

@view_flow.get(:layout).replace capture(&block)
TypeError: no implicit conversion of nil into String

capture(&block) returns nil, but the block is correct

block.call
=> [:menus]

@fractaledmind
Copy link
Contributor

So, I don't yet have a solution or an understanding of what precisely is going on, but I have found that I can "fix" this problem by ensuring there are newlines at the end of the block. So, for your example, try this:

<%=  extends :application do %>
  <% purge :menus %>

<% end %>

@rwz
Copy link
Owner

rwz commented Jun 29, 2016

Interesting. Could you a write a spec reproducing the problem?

@rwz
Copy link
Owner

rwz commented Jun 29, 2016

I'll try to take a look later today. I think I have an idea what might be going on there and what would be the easiest way to fix it.

@fractaledmind
Copy link
Contributor

I found a simple solution: capture(&block).to_s

@fractaledmind
Copy link
Contributor

It seems that the way the log works, when you initially capture the &block, nothing has been rendered yet, so it is nil. It is only after the file has been rendered (a few lines later) that things start to happen.

I can definitely write a spec to reproduce tho.

@jjercx
Copy link

jjercx commented Apr 3, 2018

Is it solved? I have the same problem @fractaledmind pointed. (Rails 5.1 btw)

This causes TypeError. no implicit conversion of nil into String

<%= extends :app do %>
  <%= replace :content do %>
    <div class="main main-raised">

      <%= flash_messages %>
      <div class="flash"></div>

      <div class="container">
        <%= yield %>
      </div>
    </div>
  <% end %>
<% end %>

This works:

<%= extends :app do %>
  <%= replace :content do %>
    <div class="main main-raised">

      <%= flash_messages %>
      <div class="flash"></div>

      <div class="container">
        <%= yield %>
      </div>
    </div>
  <% end %>

<% end %>

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

4 participants