Question: i've been thinking of what is the better way of creating a profile generation functionality, RESTwise.

The idea is that my menu always has a link to a user's profile, whether it's generated or not. However, a profile has to be generated by the user at the first time and it will then be shown to them.

To illustrate, there can be a menu item pointing to '/profiles/new' and change dynamically to 'profile/:id' once the user creates the profile for the first time. This seems natural, but i don't like that i have to get a @profile instance variable in my applications controller(since it will have to be checked everytime, to dynamically generate the link).

The other idea is to have a redirection happening, probably the best of the two. The user clicks on the /profiles/new path(or an alias) and gets redirected to 'profile/:id', if they do have a profile set already.

What do you think is the best way to do it and is there another alternative i've not thought of ?

Answer: 
A redirect doesn't quite make sense to me, RESTwise, as it introduces an ambiguous resource at `/profile/new`, but I don't think you necessarily need to get `@profile` every time. Assuming that `user_signed_in?` is a helper that would confirm that a user (`current_user`) is, in fact, signed in, you could create a link helper in your application helper directory that looks something like this:

```
def link_to_user_profile(html = {})

  if user_signed_in?
    @profile = current_user.profile
    link = profile_path(@profile)
    text = 'Your Profile'
  else
    link = new_profile_path
    text = 'Create a Profile'
  end

  link_to text, link, html
end

```

I'm making up variables all over the place, but hopefully this helps!
You can also think of building a new profile `after_create` a user with default values. In this case the user will always have a default profile.