I have a select_tag to pick items from a list here’s the code:
<%= select_tag "Drinks", options_for_select([ "Water", "Soda", "Beer" ], "Water") %>
After submiting “water” for exemple, it doesn’t show up on the index and show views, on the “Drinks” section.
What am I doing wrong?
Controllers create and update methods
def create
@facture = Facture.new(params[:facture])
respond_to do |format|
if @facture.save
format.html { redirect_to @facture, :notice => 'Facture was successfully created.' }
format.json { render :json => @facture, :status => :created, :location => @facture }
else
format.html { render :action => "new" }
format.json { render :json => @facture.errors, :status => :unprocessable_entity }
end
end
end
def update
@facture = Facture.find(params[:id])
respond_to do |format|
if @facture.update_attributes(params[:facture])
format.html { redirect_to @facture, :notice => 'Facture was successfully updated.' }
format.json { head :ok }
else
format.html { render :action => "edit" }
format.json { render :json => @facture.errors, :status => :unprocessable_entity }
end
end
end
You should use this:
The create method is using the values sent in params[:facture] and using “facture[drinks]” will include it as params[:facture][:drinks].