0

I'm a newb with Rails and am trying to get out my first Rails 3 app with Devise. I have a situation where pretty much everything on my site is specific to a user. I'm creating a kind of private gallery that isn't public facing, so that every image belongs_to a user and a user has_many images. Here's my issue... I want to rework my routes so that showing a users images doesn't require a user id in the URL. I will be showing a user's images in the user/show route.

current route (from rake:routes):

/users/show(.:format)   {:action=>"show", :controller=>"users"}

Is it possible to have devise use only "resource" instead of "resources"? so it would be /users/show/? Am I making sense? I am not sure the terminology to ask, but I want all of a user's functionality to imply that I know who the user is, then I can check that in the controllers.

Thanks!

panzhuli
  • 2,890
  • 6
  • 33
  • 46

1 Answers1

1

In your controller, for the show action:

def show
    @user = current_user
end

That's all you need to do. If you were EXPECTING an id, then you do something like @user = User.find(params[:id], but since you know what user you want (in this case, the current_user, which is exposed by Devise), you don't need to do anything special.

Intelekshual
  • 7,444
  • 1
  • 21
  • 28