Bonjour,
Voila j’epeluchais le code des scaffold genere par Rails, j’ai tout
compris a part 1 detail …
Cela concerne l’action new :
Je vois dans le controller , dans l’action new, l’instanciation de
l’objet, jusqu’a la c’est normal, dans la view, rien de special, ma
question est :
Pourquoi quand je soumets le formulaire, ca passe dans l’action create,
alors que dans la view, il n’y a aucune reference a Create …
J’ai chercher partout, dans les routes et tout je ne trouve rien …
Je vous mets le code de l’action new et create, si ca peut vous aider…
GET /products/new
GET /products/new.xml
def new
@product = Product.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @product }
end
end
POST /products
POST /products.xml
def create
@product = Product.new(params[:product])
respond_to do |format|
if @product.save
flash[:notice] = 'Product was successfully created.'
format.html { redirect_to(@product) }
format.xml { render :xml => @product, :status => :created,
:location => @product }
else
format.html { render :action => “new” }
format.xml { render :xml => @product.errors, :status =>
:unprocessable_entity }
end
end
end
Je vous remercie d’avance, je commence a devenir fou la ^^