earthcubeprojects-chords / chords

EarthCube CHORDS application code
GNU General Public License v2.0
25 stars 13 forks source link

Renew API Key action breaks on development release (660672a) #472

Closed MisterMartin closed 6 years ago

MisterMartin commented 6 years ago

Logged in as admin@chordsrt.com. When I mash the "Renew API Key" button, the users_controller breaks. params seems to be missing.

I, [2018-09-26T23:21:57.542809 #103]  INFO -- : Started PATCH "/users/1" for 127.0.0.1 at 2018-09-26 23:21:57 +0000
I, [2018-09-26T23:21:57.544043 #103]  INFO -- : Processing by UsersController#update as HTML
I, [2018-09-26T23:21:57.544150 #103]  INFO -- :   Parameters: {"utf8"=>"✓", "authenticity_token"=>"Zq9nAjcuV6o0+VWc3guMggh4uthzQpUBxffhVQP6yrBRDGjMuCgzhMRozmeS+H1jy1bwHBxngp62mV6kepBihg==", "user"=>{"email"=>"admin@chordsrt.com"}, "id"=>"1"}
D, [2018-09-26T23:21:57.545606 #103] DEBUG -- :   Profile Load (0.5ms)  SELECT  `profiles`.* FROM `profiles`  ORDER BY `profiles`.`id` ASC LIMIT 1
D, [2018-09-26T23:21:57.568117 #103] DEBUG -- :   Site Load (0.5ms)  SELECT  `sites`.* FROM `sites`  ORDER BY `sites`.`id` ASC LIMIT 1
D, [2018-09-26T23:21:57.569323 #103] DEBUG -- :   Instrument Load (0.6ms)  SELECT  `instruments`.* FROM `instruments`  ORDER BY `instruments`.`id` ASC LIMIT 1
D, [2018-09-26T23:21:57.571422 #103] DEBUG -- :   User Load (0.6ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
D, [2018-09-26T23:21:57.573096 #103] DEBUG -- :   User Load (0.4ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 1  ORDER BY `users`.`id` ASC LIMIT 1
D, [2018-09-26T23:21:57.573951 #103] DEBUG -- :   CACHE (0.0ms)  SELECT  `profiles`.* FROM `profiles`  ORDER BY `profiles`.`id` ASC LIMIT 1
I, [2018-09-26T23:21:57.575764 #103]  INFO -- : Completed 500 Internal Server Error in 31ms (ActiveRecord: 2.6ms)
F, [2018-09-26T23:21:57.577221 #103] FATAL -- :
NoMethodError (undefined method `include?' for nil:NilClass):
  app/controllers/users_controller.rb:32:in `block in update'
  app/controllers/users_controller.rb:26:in `update'
zastruga commented 6 years ago

Good catch. This is a result of changing from link_to to button_to within a form object. The form treated the button as a submit button and it was calling the update action instead of the one to reset the API Key. I changed it back to a link_to with styling consistent with the buttons on the page and will put it in with the DOI fix.