我有一個select_tag挑選從這裏列表中的項目的問題是代碼:Rails的select_tag在表演和索引操作
<%= select_tag "Drinks", options_for_select([ "Water", "Soda", "Beer" ], "Water") %>
submiting「水」爲爲例之後,它不會對指數出現了,在「飲料」部分展示意見。
我在做什麼錯?
控制器創建和更新方法
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
你正在顯示的代碼是索引和顯示嗎? – Salil
實際的代碼是關閉的「_form.html.erb」 – blawzoo
請發佈您的控制器的創建/更新代碼 – arnep