我在ClientsController
上創建了一個名爲update_establishments
的新操作。我有一個Client
的表格,我想在不生成新視圖的情況下調用該操作。該行動將產生新的觀點。RoR - 在窗體上不顯示視圖的情況下調用新操作
clients_controller.rb def update_establishments create_zip respond_to do |format| if @client.update(client_params) set_zip format.html { redirect_to @client, notice:'Estabelecimento adicionado com sucesso.'} format.json {head :no_content} else format.html { render action: 'edit'} format.json { render json: @client.error, status: :unprocessable_entity } end end end clients/_locations_form.html.erb form_for @client, :url=>{:action=>'update_establishments'} do |form| %> ...
,這將引發與解釋No route matches {:action=>"update_establishments", :id=>"35", :controller=>"clients"}
錯誤ActionController::UrlGenerationError in Clients#add_establishments
我在routes.rb
不需要做任何改變,我需要創建一個視圖名爲clients/update_establishments
,使這項工作?