jatwell93 / rubyproject

1 stars 1 forks source link

Logout Error - All pages #19

Closed Mirv closed 7 years ago

Mirv commented 7 years ago

ActiveRecord::RecordNotFound in UsersController#show Couldn't find User with 'id'=sign_out


Extracted source (around line #66):

private def set_user @user = User.find(params[:id]) end

def user_params
jatwell93 commented 7 years ago

this has been the error i've been struggling with for the past week. I've seen similar issues on Stack Overflow however all their fixes havent seemed to work yet,. I'll continue playing around with this one today

jatwell93 commented 7 years ago

I believe this was because i had //= require jquery_ujs in the wrong spot. Are you still getting this error on your end?

Mirv commented 7 years ago

You know, I can see any commits pushed to fix it - but for now it's working again - very odd - might be looking at edgecase or exception.

jatwell93 commented 7 years ago

@Mirv I'm getting this one again how about you?

Mirv commented 7 years ago

I found out my job is on the chopping block this week so not as much time as I used to have...

My take on it is that the route to sign out needs to be before the route for users (in your case devise_for users).

I pulled your last commit & saw physically you moved both of those things, but when you moved them, you kept the order as devise_for users, then the signout route ... which as far as I could guess does nothing about the issue.

Per: http://stackoverflow.com/questions/22490555/couldnt-find-user-with-id-sign-out#

Mirv commented 7 years ago

I found a blurb in there about periodic issues (randomly, not all the time) with jquery-ujs ... had you seen it?

I had the same issue, my routes were in the correct order, the link_to method properly used and rails kept triggering the users/:id route with :id => :sign_out I figured out that was because I removed jquery_ujs from my application.js file...

jquery_ujs handles the data-method attribute in the links (generated by link_to when you use the method option), which is used to determine the correct route as explained here : http://robots.thoughtbot.com/a-tour-of-rails-jquery-ujs

So just make sure the you have the following included in your application.js

//= require jquery
//= require jquery_ujs
Mirv commented 7 years ago

Follow by comment ... Awesome answer. Struggled with this for a while, and kept staring at the routes, which looked perfect. Alas, it was javascript! I had 'jquery_ujs', but it was after my bootstrap, require so I changed the order to: //= require jquery //= require jquery_ujs //= require bootstrap – Carson Cole Aug 29 '16 at 20:46

jatwell93 commented 7 years ago

Sorry to hear about your job! You seem incredibly intelligent so I'm sure you cand work anywhere :) I'm heading to japan for a fortnight in a couple of days so i doubt i'll be online much either.

I thought javascript might be the issue for a couple of these bugs we're having, just a gut instinct for some reason. I had a muck around with the ordering or removing it but didnt seem to do anything. Could it have been when i was clearing out the conflicts i've mucked something up?

jatwell93 commented 7 years ago

I think this is all fixed now, ujs wasn't in the asset file >.< i must have deleted it at some point (i think to try to get jQuery not to load twice) thats why the error reoccurred. sorry about that!

i believe this may help fix a few more errors we're having though!

Mirv commented 7 years ago

Excellent looking better & better!