I have a Post model with a one-to-many relationship with a Comments model. I'm using simple_form in a partial to create some quick forms (specifically, for the comment model) for my user interface:
<%= simple_form_for(@post, Comment.new) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :comment, :input_html => {:rows => 20, :class => 'span12'} %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>
However, Rails fails with the following error: can't write unknown attribute 'builder'
and the stack trace pointing to the first line (<%= simple_form_for(@post, Comment.new) do |f| %>
).
Where does this builder attribute come from and how can I make this work? Thanks.
I guess you use nested resources
. If so, AFAIK, you should pass an array to simple_form_for
method as first parameter (responsible for setting the proper form URL):
<%= simple_form_for [@post, Comment.new] do |f| %>
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