Reputation: 221
trying to wrap my head round something and hoping someone can help.
I have a loop as follows to dislay a list of assets (images) for a property:
- @property.property_assets.each do |asset|
Each asset has an image with a description field, ie:
= asset.description
This works perfectly fine.
I'd like to have a form for each asset so I can update the description, with a submit.
My form_for currently looks like:
= form_for asset , url: property_property_assets_path do |f|
My routes file:
resources :properties do
resources :property_assets
member do
post :update_general
post :update_promo_image
post :update_location
end
end
My property_assets_controller:
def index
@property = Property.find(params[:property_id])
end
def update
if @property_asset.update(property_asset_params)
respond_to do |format|
format.html
format.js
flash[:notice] = "Updated property asset"
end
else
render 'edit'
end
end
The issue
I'm getting the error:
No route matches {:action=>"index", :controller=>"property_assets", :id=>"1"} missing required keys: [:property_id]
Thanks in advance
Upvotes: 0
Views: 26