ruby on rails - Update method is passing id in a weird way -


somehow, update method after editing passing id "show"

here @ parameters being passed when "update"\

started patch "/owners/show.3328" 127.0.0.1 @ 2016-11-08 12:28:29 +0200 processing ownerscontroller#update    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".* "users" "users"."id" = $1 order "users"."id" asc limit $2  [["id", 1], ["limit", 1]]   shop load (0.3ms)  select  "shops".* "shops" "shops"."id" = $1 limit $2  [["id", 1], ["limit", 1]]   owner load (0.5ms)  select  "owners".* "owners" "owners"."shop_id" = $1 , "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 'id'=show [where "owners"."shop_id" = $1]): 

my form is, same form new owner (and works):

<%=form_for @owner , remote: true |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 same save.js.erb works find when creating new owner.

the preferred way of creating restful routes in rails using resources:

resources :owners 

which give get /owners/:id canonical rails rest route points show action on ownerscontroller.

don't create routes such as:

/owners/show /owners/index /owners/create 

unless want incompetent. in rails actions inferred http verb used , presence of dynamic id segment on end.

see:


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -