سؤال

In my app I assign a url's href attribute as profile_path when using resources :profiles in my routes.rb file. I do not pass any id into profile_path yet the app somehow correctly assumes that it is the profile of the current_user. How does rails know this? Is this simply a default that rails assumes if you don't pass in an id?

هل كانت مفيدة؟

المحلول

If you have set up a before_filter in your controller with Devise where profile_path requires a user to sign in first, it will default to the current_user helper to send the current_user's id along with the request.

As an aside to the question's comment thread, to test what routes you have set up, run rake routes in terminal and you'll see if you have Devise routes set up.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top