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?
Asked
Active
Viewed 129 times
0

Justin Meltzer
- 13,318
- 32
- 117
- 182
-
actually I am using Devise for authentication, not sure if that makes a difference – Justin Meltzer Nov 25 '11 at 20:24
-
And the profile paths are set up as devise paths? That's how :) – Dave Newton Nov 25 '11 at 20:25
-
@DᴀᴠᴇNᴇᴡᴛᴏɴ umm I don't think they are... – Justin Meltzer Nov 25 '11 at 20:30
-
You're saying that neither your routes, nor your models, have anything to do with devise? – Dave Newton Nov 25 '11 at 20:39
-
@DᴀᴠᴇNᴇᴡᴛᴏɴ as far as I can tell, not the profile model or routes... – Justin Meltzer Nov 25 '11 at 21:00
-
And you don't have any devise filters/superclasses set up on any of your controllers? I'm confused; you say you have no devise routes, no devise in your models; did you use the view generators? – Dave Newton Nov 25 '11 at 21:03
-
@DᴀᴠᴇNᴇᴡᴛᴏɴ well these are the Devise routes I have enabled: `devise_for :users, :controllers => { :registrations => 'registrations'}` – Justin Meltzer Nov 25 '11 at 21:35
-
And so I assume I'd be using Devise's superclasses for that, as well as its `current_user` method – Justin Meltzer Nov 25 '11 at 21:38
1 Answers
0
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.

Simpleton
- 6,285
- 11
- 53
- 87