forms - Rails Using Edit action in a Show View -
i'm trying update object in it's show view. i've been following railscasts habtm checkboxes.
getting following error:
no route matches [put] "/accounts/4/edit"
here form:
<%= form_for @account, :url => { :action => "edit"} |form| %> <%= hidden_field_tag "account[checklist_ids][]", nil%> <% checklist.all.each |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
<%= form_for @account, :url => { :action => "edit"} |form| %>
change to
<%= form_for(@account) |form| %>
Comments
Post a Comment