我正在尝试更新其显示视图中的对象。我一直在关注 railscasts HABTM checkboxes。
收到以下错误:
没有路线匹配 [PUT] "/accounts/4/edit"
这是我的表格:
<%= form_for @account, :url => { :action => "edit"} do |form| %>
<%= hidden_field_tag "account[checklist_ids][]", nil%>
<% Checklist.all.each do |checklist| %>
<%= check_box_tag "account[checklist_ids][]", checklist.id, @account.checklist_ids.include?(checklist.id) %>
<%= checklist.task %><br/>
<% end %><br/>
<%= form.submit "Update Checklist", class: 'btn' %>
<% end %>
/app/controllers/accounts_controller.rb
class AccountsController < ApplicationController
before_filter :authenticate_user!
respond_to :html, :json
def show
@account = Account.find(params[:id])
@notes = @account.notes.all
@contacts = @account.contacts.all
end
def edit
@account = Account.find(params[:id])
end
def update
@account = Account.find(params[:id])
@account.update_attributes(params[:account])
respond_with @account
end
end
/app/models/account.rb
class Account < ActiveRecord::Base
attr_accessible :address, :city, :name, :phone, :state, :website, :zip, :contactname
attr_accessible :conferences_attributes, :checklists_attributes
has_many :notes, :dependent => :destroy
has_many :accountchecklists
has_many :checklists, :through => :accountchecklists, :dependent => :destroy
has_many :contacts, :dependent => :destroy
has_and_belongs_to_many :conferences
accepts_nested_attributes_for :conferences
accepts_nested_attributes_for :checklists
end