Essayer de recréer {script/generate échafaudage}, et j'ai obtenu un certain nombre de bases Rails. Je suspecte que j'ai besoin de configurer l'URL de produit par défaut quelque part. Mais où est-ce que je fais ça?Comment puis-je configurer mon @ produit = Product.find (params [: id]) pour avoir un product_url?
Configuration:
- ont: modifier def {@ produit = Product.find (params [: id])}
- Avez edit.html.erb, avec une édition sous forme d'affichage action =>: créer
- Avez créer def {...}, avec le code redirect_to (@product, ...)
- Obtenir erreur: méthode non définie Product_URL » pour # < ProduitsController: 0x56102b0>
Ma mise à jour def:
def update
@product = Product.find(params[:id])
respond_to do |format|
if @product.update_attributes(params[:product])
format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
end
end
end
[modifier] Oh, c'est vous qui avez répondu à la question :) –