You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
I am trying to get the nested_form gem to work in rails 4.1 for adding attachments using paperclip. Everything renders as expected but when I submit the form nothing happens. No errors, no log output or anything.
I am not sure the best way to debug this problem since I basically don't have anything to go on. Has anyone else has run into this problem or can you give advice for the best way I can attack this?
What I currently have is as follows:
discussions_controller.rb:
def new
@discussion = Discussion.new
@discussion_group = DiscussionGroup.find(params[:discussion_group_id])
@categories = DiscussionCategory.all.collect{|category| [category.name, category.id]}
2.times{@discussion.discussion_attachments.build}
end
def discussion_params
params.require(:discussion).permit(:discussion_group_id, :discussion_category_id, :subject, :body, discussion_attachments_attributes: [:id, :name, :_destroy])
end
<%= form_for @discussion, url: admin_discussions_path, method: :post do |f| %>
<%= nested_form_for @discussion do |f| %>
Upload Document
<%= f.fields_for :discussion_attachments do |builder| %>
<div class='field'>
<%= builder.file_field :document %>
<%= builder.link_to_remove "Remove this document" %>
</div>
<% end %>
<%= f.link_to_add "Add a document", :discussion_attachments %>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
UPDATE:
The form works as it is supposed to when I uncomment the nested_form_for block. But the moment I uncomment that block but leave the fields_for block on the inside of that commented out this issue shows. This same issue happens in rails 4.0.4.
The text was updated successfully, but these errors were encountered:
Hello,
I am trying to get the nested_form gem to work in rails 4.1 for adding attachments using paperclip. Everything renders as expected but when I submit the form nothing happens. No errors, no log output or anything.
I am not sure the best way to debug this problem since I basically don't have anything to go on. Has anyone else has run into this problem or can you give advice for the best way I can attack this?
What I currently have is as follows:
discussions_controller.rb:
discussion.rb
discussion_attachment.rb
new.html.erb
UPDATE:
The form works as it is supposed to when I uncomment the nested_form_for block. But the moment I uncomment that block but leave the fields_for block on the inside of that commented out this issue shows. This same issue happens in rails 4.0.4.
The text was updated successfully, but these errors were encountered: