使用载波将 "Add more documents feature" 添加到 rails 应用
Adding "Add more documents feature" to rails app using carrierwave
我正在尝试使用载波 gem 添加向我的 rails 应用程序添加更多文档的功能。 I am following this tutorial for it。我收到一个错误。
syntax error, unexpected ',', expecting keyword_end
syntax error, unexpected tLABEL
applicationshow.html.erb
<p>
<span class="text-label">Client Last Name:</span>
<%= @application.user.lastname %>
</p>
<p>
<span class="text-label">Client First Name:</span>
<%= link_to @application.user.firstname, user_path(@user) %>
</p>
<p>
<span class="text-label">Clinic:</span>
<%= @application.clinic_name %>
</p>
<p>
<span class="text-label">Applicant name:</span>
<%= @application.applicant_name %>
</p>
<p>
<span class="text-label">Application Status:</span>
<%= @application.status %>
</p>
<% @application.documents.each_with_index do |document, index| #grab the index %>
<%= image_tag(document.url) %>
<%= link_to "Delete", user_application_document_path(@user, @application, index), :method => :delete, data: { confirm: "Are you sure you want to delete this document?", class: "btn btn-xs btn-danger" } %>
<% end %>
<%= form_for([@user, @application]), url: user_application_documents_path(@user, @application), method: :post do |f| %>
<div class="field">
<%= f.file_field :documents, multiple: true %>
</div>
<div class="actions">
<%= f.submit "Add More Documents" %>
</div>
<% end %>
documents_controller.rb
before_action :set_user
before_action :set_application
def create
add_more_documents(documents_params[:documents])
flash[:error] = "Failed uploading documents" unless @application.save
redirect_back fallback_location: user_application_path(@user)
end
private
def set_applicaion
@applicaion = Applcation.find(params[:application_id])
end
def set_user
@user = User.find(params[:user_id])
end
def add_more_documents(new_documents)
documents = @application.documents
documents += new_documents
@application.documents = documents
end
def documents_params
params.require(:application).permit({documents: []})
end
请帮我定位错误。错误显示在表单添加更多文档的行上。
这是一个简单的错位括号。 form_for([@user, @application]),
。它应该是:
<%= form_for([@user, @application], url: user_application_documents_path(@user, @application), method: :post) do |f| %>
我正在尝试使用载波 gem 添加向我的 rails 应用程序添加更多文档的功能。 I am following this tutorial for it。我收到一个错误。
syntax error, unexpected ',', expecting keyword_end
syntax error, unexpected tLABEL
applicationshow.html.erb
<p>
<span class="text-label">Client Last Name:</span>
<%= @application.user.lastname %>
</p>
<p>
<span class="text-label">Client First Name:</span>
<%= link_to @application.user.firstname, user_path(@user) %>
</p>
<p>
<span class="text-label">Clinic:</span>
<%= @application.clinic_name %>
</p>
<p>
<span class="text-label">Applicant name:</span>
<%= @application.applicant_name %>
</p>
<p>
<span class="text-label">Application Status:</span>
<%= @application.status %>
</p>
<% @application.documents.each_with_index do |document, index| #grab the index %>
<%= image_tag(document.url) %>
<%= link_to "Delete", user_application_document_path(@user, @application, index), :method => :delete, data: { confirm: "Are you sure you want to delete this document?", class: "btn btn-xs btn-danger" } %>
<% end %>
<%= form_for([@user, @application]), url: user_application_documents_path(@user, @application), method: :post do |f| %>
<div class="field">
<%= f.file_field :documents, multiple: true %>
</div>
<div class="actions">
<%= f.submit "Add More Documents" %>
</div>
<% end %>
documents_controller.rb
before_action :set_user
before_action :set_application
def create
add_more_documents(documents_params[:documents])
flash[:error] = "Failed uploading documents" unless @application.save
redirect_back fallback_location: user_application_path(@user)
end
private
def set_applicaion
@applicaion = Applcation.find(params[:application_id])
end
def set_user
@user = User.find(params[:user_id])
end
def add_more_documents(new_documents)
documents = @application.documents
documents += new_documents
@application.documents = documents
end
def documents_params
params.require(:application).permit({documents: []})
end
请帮我定位错误。错误显示在表单添加更多文档的行上。
这是一个简单的错位括号。 form_for([@user, @application]),
。它应该是:
<%= form_for([@user, @application], url: user_application_documents_path(@user, @application), method: :post) do |f| %>