I have a Devise form configured in my application to update a portion of user information (mailing address fields) from another page ( charges#new
), and the server output seems to indicate its operation:
Started PUT "/users" for ::1 at 2017-05-11 17:10:52 -0700
Processing by RegistrationsController
Parameters: {"utf8"=>"✓", "user"=>{"street_address_1"=>"**street address**", "street_address_2"=>"", "city"=>"**city**", "state"=>"CA", "zip"=>"**zip code**", "provence"=>"", "country"=>"United States", "has_shipping"=>"true"}, "commit"=>"Calculate Shipping"}
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
Order Load (0.1ms) SELECT "orders".* FROM "orders" WHERE "orders"."id" = ? LIMIT 1 [["id", 5]]
CACHE (0.0ms) SELECT "orders".* FROM "orders" WHERE "orders"."id" = ? LIMIT 1 [["id", 5]]
Rendered charges/_shipping.html.erb (5.0ms)
Rendered devise/registrations/update.js.erb (6.4ms)
Completed 200 OK in 150ms (Views: 26.1ms | ActiveRecord: 0.3ms)
However, when I check the console, it still has not updated the information.
My registrations_controller
:
class RegistrationsController < Devise::RegistrationsController
respond_to :html, :js
private
def sign_up_params
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :phone, :stripe_customer_id, :street_address_1, :street_address_2, :city, :state, :zip, :provence, :country, :has_shipping)
end
def account_update_params
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :current_password, :phone, :admin, :stripe_customer_id, :street_address_1, :street_address_2, :city, :state, :zip, :provence, :country, :has_shipping)
end
end
I have the following update.js.erb
:
$(".shipping-info").html("<%= escape_javascript(render 'charges/shipping') %>")
This is mine charges#new
:
<div class="product-row black-border-row row" style="margin-bottom: 60px">
<div class="container">
<%= render "shipping" %>
</div>
</div>
And here is _shipping.html.erb
partial:
<div class="row text-center">
<h3>Shipping Address</h3>
<%= simple_form_for(@user, url: registration_path(@user), html: { method: :put }, remote: true) do |f| %>
<div class="form-inputs text-left">
<div class="form-group col-sm-6">
<%= f.label :street_address_1 %>
<%= f.text_field :street_address_1, class: "form-control" %>
</div>
<div class="form-group col-sm-6">
<%= f.label :street_address_2 %>
<%= f.text_field :street_address_2, class: "form-control" %>
</div>
<div class="form-group col-sm-6">
<%= f.label :city %>
<%= f.text_field :city, class: "form-control" %>
</div><div class="form-group col-sm-3 col-xs-6">
<%= f.label :state %>
<%= f.text_field :state, class: "form-control" %>
</div><div class="form-group col-sm-3 col-xs-6">
<%= f.label :zip %>
<%= f.text_field :zip, class: "form-control" %>
</div><div class="form-group col-sm-6">
<%= f.label :provence %>
<%= f.text_field :provence, class: "form-control" %>
</div><div class="form-group col-sm-6">
<%= f.label :country %>
<%= f.text_field :country, class: "form-control" %>
</div><div class="form-group">
<%= f.hidden_field :has_shipping, value: true %>
</div>
</div>
<%= f.button :submit, "Calculate Shipping" %>
<% end %>
</div>
Can anyone understand why this is not updating the table?
EDIT: ROUTES
As requested, here are my routes:
orders_update GET /orders/update(.:format) orders
new_user_session GET /users/sign_in(.:format) devise/sessions
user_session POST /users/sign_in(.:format) devise/sessions
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions
user_password POST /users/password(.:format) devise/passwords
new_user_password GET /users/password/new(.:format) devise/passwords
edit_user_password GET /users/password/edit(.:format) devise/passwords
PATCH /users/password(.:format) devise/passwords
PUT /users/password(.:format) devise/passwords
cancel_user_registration GET /users/cancel(.:format) registrations
user_registration POST /users(.:format) registrations
new_user_registration GET /users/sign_up(.:format) registrations
edit_user_registration GET /users/edit(.:format) registrations
PATCH /users(.:format) registrations
PUT /users(.:format) registrations
DELETE /users(.:format) registrations
user GET /users/:id(.:format) users
home_index GET /home/index(.:format) home
root GET / home
home_info GET /home/info(.:format) home
home_export GET /home/export(.:format) home
home_kits GET /home/kits(.:format) home
products GET /products(.:format) products
POST /products(.:format) products
new_product GET /products/new(.:format) products
edit_product GET /products/:id/edit(.:format) products
product GET /products/:id(.:format) products
PATCH /products/:id(.:format) products
PUT /products/:id(.:format) products
DELETE /products/:id(.:format) products
tag GET /tags/:tag(.:format) products
cart GET /cart(.:format) carts
order_items POST /order_items(.:format) order_items
order_item PATCH /order_items/:id(.:format) order_items
PUT /order_items/:id(.:format) order_items
DELETE /order_items/:id(.:format) order_items
orders POST /orders(.:format) orders
edit_order GET /orders/:id/edit(.:format) orders
order GET /orders/:id(.:format) orders
PATCH /orders/:id(.:format) orders
PUT /orders/:id(.:format) orders
charges GET /charges(.:format) charges
POST /charges(.:format) charges
new_charge GET /charges/new(.:format) charges
edit_charge GET /charges/:id/edit(.:format) charges
charge GET /charges/:id(.:format) charges
PATCH /charges/:id(.:format) charges
PUT /charges/:id(.:format) charges
DELETE /charges/:id(.:format) charges
And here are my respective routes:
get 'orders/update'
devise_for :users, :controllers => { registrations: 'registrations' }
resources :users, only: [:show]
get 'home/index'
root 'home
get 'home/info'
get 'home/export'
get 'home/kits'
resources :products
get 'tags/:tag', to: 'products#index', as: :tag
resource :cart, only: [:show]
resources :order_items, only: [:create, :update, :destroy]
resources :orders, only: [:update, :edit, :show, :create]
resources :contacts
put "contacts/:id/archive" => "contacts#archive", as: "archive_contact"
put "contacts/:id/unarchive" => "contacts#unarchive", as: "unarchive_contact"
resources :charges