I'm recreating the steps in this rails tutorial: http://www.youtube.com/watch?v=tUH1hewXnC0
If you seek to 7:35, you'll see a form_for block the user has created. When I add that code and view the page in a browser, the page renders fine but there's no html where the form should be -- not even empty tags. I've confirmed that it's not an issue with a missing migration or browser cacheing.
I've simplified the problem down, and now my show.html.erb template file is just:
<% form_for @post do |f| %>
testing
<% debugger %>
<% end %>
<% for i in 0..5 %>
<%= i %>
<% end %>
(The second block is just to make sure the rendering is working)
The rendered html is:
... bunch of header stuff here ...
<body>
0
1
2
3
4
5
</body>
</html>
"testing" is not getting rendered as part of the html.
I put in that debugger line so I could use the debugger gem with rails server --debugger . Using that gets me to this point:
[196, 205] in /Users/Ben/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_view/helpers/capture_helper.rb
196 buf = ActionView::OutputBuffer.new
197 buf.force_encoding(output_buffer.encoding) if output_buffer
198 end
199 self.output_buffer, old_buffer = buf, output_buffer
200 yield
=> 201 output_buffer
202 ensure
203 self.output_buffer = old_buffer
204 end
205
(rdb:48) p output_buffer
" testing\n"
So, the form_for is getting executed, but not getting delivered all the way through to the output html somehow. (that's why I'm not bothering to show you that I'm correctly initializing @post.)
I can't find any mention of similar problems online, but I'm probably just not looking for the right things. Any ideas?
You're missing the =
sign: <%= form_for @post do |f| %>
Figured it out as soon as I finished writing question (always seems to happen on stackoverflow!)
On the form_for line, <% should instead be <%= .
I suppose that changed at some point in rails?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With