I follow the tutorial of Ryan Bates that Jquery file upload but the example was only 1 model. I tried to make a version for my application that serviceproviders has_many photos and photos belongs_to serviceprovider.
This is my new.html.erb
<h1>Add a Clearance</h1>
<%= form_for Clearance.new do |f| %>
<%= f.label :avatar, "Clearances" %>
<%= f.file_field :avatar, multiple: true, name: "clearance[avatar]" %>
<% end %>
Clearance controller
def new
@serviceprovider = Serviceprovider.find(params[:serviceprovider_id]
@clearance = @serviceprovider.clearances.new
end
def create
@clearance = Clearance.create(clearance_params)
end
And I got an error undefined method "clearances_path"
How can I upload a photo with associated models. Thank you!
**
Update
**
I'm trying to create a galleries of photo of clearances for Serviceproviders. For example a serviceproviders has a Police clearance, NBI Clearance and any clearances that may notify that he had no any criminal cases. Now I can upload the photo using the jquery-fileupload (thanks for @OlivierLance for helping me) but now I want every time I upload the photo it will automatically display. I new to rails and I have a hard time to learn some gems because as I said I'm not familiar in rails. I already the solutions that I will reload the page so that it will display every time I upload but nothings happen. The page had a infinite loop redirecting the page.
def new
@serviceprovider = Serviceprovider.find(params[:serviceprovider_id])
@clearance = @serviceprovider.clearances.new
@clearances = @serviceprovider.clearances
redirect_to new_serviceprovider_clearance_url(@serviceprovider)
end
end
def create
@serviceprovider = Serviceprovider.find(params[:clearance][:serviceprovider_id])
@clearance = @serviceprovider.clearances.create(clearance_params)
end
How can I achieve that?