i have "accounts" page in rails 4 app allow user update various settings including his/her password. i'm using devise authentication. followed instructions under solution 3 allow custom update action. should getting directed action "accounts#update_password", keep getting redirected "accounts#index". setup looks following.
# routes.rb rails.application.routes.draw post '/accounts/update_password', to: 'accounts#update_password' '/accounts', to: 'accounts#index' end # controllers/accounts_controller.rb class accountscontroller < applicationcontroller def index # gets here end def update_password # never gets here end end # views/accounts/index.html.erb ... form_for(@customer, :url => {:action => "update_password"}, :html => { :method => :post, :role => 'form'} ) |f| %> ... <% end %> ... the html renders following form header, looks correct me.
<form role="form" class="edit_customer" id="edit_customer_1" action="/accounts/update_password" accept-charset="utf-8" method="post"><input name="utf8" type="hidden" value="✓" /><input type="hidden" name="authenticity_token" value="xxx==" /> but server log shows following request.
get /accounts?utf8=%e2%9c%93&authenticity_token=xxx&customer%5bcurrent_password%5d=11111111&customer%5bpassword%5d=11111111&customer%5bpassword_confirmation%5d=11111111&commit=reset http/1.1 so appears somehow post /accounts/update_password being rewritten /accounts. guess there devise magic causing rewrite, cannot figure how go debugging it.
below entire server log account page, , password update:
desktop:~/rails$ bundle exec foreman start 12:05:22 web.1 | started pid 27277 12:05:23 web.1 | puma starting in single mode... 12:05:23 web.1 | * version 2.11.3 (ruby 2.2.2-p95), codename: intrepid squirrel 12:05:23 web.1 | * min threads: 0, max threads: 16 12:05:23 web.1 | * environment: development 12:05:25 web.1 | * listening on tcp://0.0.0.0:8081 12:05:25 web.1 | use ctrl-c stop 12:05:28 web.1 | inside accounts#index 12:05:28 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:28 -0400] "get /accounts http/1.1" 200 - 0.5945 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap.min.self-a28237ec815e3256e572ee58558ef64d97fc965f398dbb27b4c49f0c3cc9e81c.css?body=1 http/1.1" 304 - 0.0061 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /font-awesome.self-2d17540bab3759939e910ca38a695f014e0c777ded3ad7a01c4658b9d3fc980d.css?body=1 http/1.1" 304 - 0.0105 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /application.self-167193cd81d9330d9ddb5c4ec7b44214fea529aa8a94f3a86e6526e4f652fc02.css?body=1 http/1.1" 304 - 0.0121 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /admin.self-e5a326677fb0496249e2d9b207e088d8ade53b63199a9afc10e4d5c34a8fe852.css?body=1 http/1.1" 304 - 0.0171 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /dashboard.self-a8a7602dfaa8429fc80356922713d926a873b01e816533dd35e7da4fd4f17b4f.css?body=1 http/1.1" 304 - 0.0052 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /home.self-ef17fc5eca46c82c6b12e059a8fe09c95fbe5d83509f5076935e079e4dd1cb35.css?body=1 http/1.1" 304 - 0.0062 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /main.self-915a7c6ba085c5ebc5049d24d148d1a4bdfc2796a1dccc6fa446265baef35feb.css?body=1 http/1.1" 304 - 0.0090 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /pics.self-4fdd597579d18c7b2af45e9bba2490c4df39173c4cf2efc8b0378f5b7d8fa2a0.css?body=1 http/1.1" 304 - 0.0103 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /jquery.self-d03a5518f45df77341bdbe6201ba3bfa547ebba8ed64f0ea56bfa5f96ea7c074.js?body=1 http/1.1" 304 - 0.0101 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /jquery_ujs.self-8e98a7a072a6cee1372d19fff9ff3e6aa1e39a37d89d6f06861637d061113ee7.js?body=1 http/1.1" 304 - 0.0043 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /turbolinks.self-c37727e9bd6b2735da5c311aa83fead54ed0be6cc8bd9a65309e9c5abe2cbfff.js?body=1 http/1.1" 304 - 0.0036 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /main.self-5cfa1d5e9516170b67ca01262910f283bee073bfa58864b31a7268223072f72f.js?body=1 http/1.1" 304 - 0.0035 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/affix.self-68d1a5161d04ca9fe1b9d9f4114d9426c7798bf90f2703a97aca35c8113469bb.js?body=1 http/1.1" 304 - 0.0068 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/alert.self-15ce09eba576e56db3edfd87accc0ff48823df915169e350b4fd97290f96aee1.js?body=1 http/1.1" 304 - 0.0110 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/button.self-37c62bff1d75f86f3348b8679873d5156d8b9938b62841038dca21690f4740f1.js?body=1 http/1.1" 304 - 0.0099 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/carousel.self-9aaab1a477b9c1156bab751cb8da47f77dace6da88eef8ae830e60f3cff3a8be.js?body=1 http/1.1" 304 - 0.0047 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/collapse.self-eeece00cd06a3d7cc071ab7845b549d4991edd0f0895e4be70fe40bac2fb5f4b.js?body=1 http/1.1" 304 - 0.0045 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/dropdown.self-a3998e7ca949c04cb86b5c635deb0abcc7a24dc02e81be66b8acfef02d811e45.js?body=1 http/1.1" 304 - 0.0047 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/modal.self-f2759e138605770e60526c00c6d86cbb3378da203641f9d6b204c9f0192b9267.js?body=1 http/1.1" 304 - 0.0064 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/scrollspy.self-5ea180afe4404f83fc97d997833f2edefd34475b0b5ddab310e27abc2bbd5f2f.js?body=1 http/1.1" 304 - 0.0052 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/tab.self-e1bba7115c90301056ee94c4716de2fcbe4498015def2dab9ff9879f339bd245.js?body=1 http/1.1" 304 - 0.0049 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/transition.self-7742dca5e6acf313fbb217811b48468282cddf1a9baea5c89ec92e367ef242cb.js?body=1 http/1.1" 304 - 0.0046 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/tooltip.self-c3b5c16f394ab9c0391db4431aac4f2d2ddf1bba4c5d3228ed343de05ecc8e83.js?body=1 http/1.1" 304 - 0.0057 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap-sprockets.self-fbfa5ad7d9aa0afe439ec4ff3883acc4cb92b62cb67c40d674320c9aa1d4642d.js?body=1 http/1.1" 304 - 0.0082 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /application.self-f98a0dd27ad1c55b2b9cfe97296d4887e5d4a4535b3bbbf9130c1050771738b2.js?body=1 http/1.1" 304 - 0.0104 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /new_green_text-81b57c23c029666f646160a5a8259a3f1b19f232aa61298d117083890ea4653f.png http/1.1" 304 - 0.0137 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /bootstrap/popover.self-2674d99c3ab0415dba0b958a80b3840f70ff6368b155d890306c0291be49453b.js?body=1 http/1.1" 304 - 0.0166 12:05:29 web.1 | 192.168.0.100 - - [16/jul/2015:12:05:29 -0400] "get /favicon_blue-95baeb74af8071a4a6f5363edb0dd8c4c5b947cde77a70fdd4438c183b928296.ico http/1.1" 200 1150 0.0040 12:08:51 web.1 | inside accounts#index 12:08:51 web.1 | 192.168.0.100 - - [16/jul/2015:12:08:51 -0400] "get /accounts?utf8=%e2%9c%93&_method=patch&authenticity_token=xxx%5bcurrent_password%5d=11111111&customer%5bpassword%5d=11111111&customer%5bpassword_confirmation%5d=11111111&commit=reset http/1.1" 200 - 0.1868
Comments
Post a Comment