Somehow, my update method after editing is passing the id as "show"
here is a look at the parameters being passed when I "update"\
Started PATCH "/owners/show.3328" for 127.0.0.1 at 2016-11-08 12:28:29 +0200
Processing by OwnersController#update as
Parameters: {"utf8"=>"✓", "owner"=>{"name"=>"Kamal Ghool", "phone"=>"05222123123", "email"=>"kamal057@gmail.com", "notes"=>"", "customer_id"=>"", "phone2"=>"", "address1"=>"Omar ben khattab St", "city"=>"Umm el fahem", "zipcode"=>"30010"}, "commit"=>"עדכון לקוח", "id"=>"show"}
User Load (0.9ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]]
Shop Load (0.3ms) SELECT "shops".* FROM "shops" WHERE "shops"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
Owner Load (0.5ms) SELECT "owners".* FROM "owners" WHERE "owners"."shop_id" = $1 AND "owners"."id" = $2 LIMIT $3 [["shop_id", 1], ["id", 0], ["LIMIT", 1]]
Completed 404 Not Found in 31ms (ActiveRecord: 1.7ms)
ActiveRecord::RecordNotFound (Couldn't find Owner with 'id'=show [WHERE "owners"."shop_id" = $1]):
My form is, which is the same form for new owner (and works):
<%=form_for @owner , remote: true do |f| %>
<div class="modal-body">
<div class="row">
<div>
<div class="col-md-6" style="float: right">
<div class="form-group">
<%#= f.hidden_field :owner_id, { :value => @owner.id } %>
<%= f.label 'שם לקוח', class:"control-label" %>
<%= f.text_field :name, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label 'טלפון לקוח', class: "control-label" %>
<%= f.text_field :phone, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label 'דוא"ל', class:"control-label" %>
<%= f.text_field :email, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label 'הערות ללקוח', class: "control-label" %>
<%= f.text_field :notes, class: "form-control" %>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<%= f.label 'ת"ז', class:"control-label" %>
<%= f.text_field :customer_id, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label 'טלפון נוסף', class: "control-label" %>
<%= f.text_field :phone2, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label 'כתובת', class:"control-label" %>
<%= f.text_field :address1, class: "form-control" %>
</div>
<div class="row">
<div class="form-group col-xs-6">
<%= f.label 'עיר', class:"control-label" %>
<%= f.text_field :city, class: "form-control col-xs2" %>
</div>
<div class="form-group col-xs-6">
<%= f.label 'מיקוד', class:"control-label" %>
<%= f.text_field :zipcode, class: "form-control col-xs2" %>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<%= f.submit class: "btn btn-primary" %>
<%= link_to "Cancel", "#", class: "btn", data: {dismiss: "modal"} %>
</div>
the update.html.erb renders the same save.js.erb which works find when creating a new Owner.
Aucun commentaire:
Enregistrer un commentaire