Adnan
Adnan

Reputation: 8729

Ruby on Rails : Create user profile in rails

I'm using devise gem. So, I can easily edit current user account by generating devise views. I've already a model user and it's related to devise gem for authenticating purpose. Now, I want to show user profile or user information in a single page. I can do it by creating a new controller. But, is it efficient or recommended way to do that??

Upvotes: 1

Views: 2354

Answers (2)

Ryan.lay
Ryan.lay

Reputation: 1761

There's no performance penalty for creating another controller, all it does is help you organize your code. Here's how I did it:

**controller**
class UsersController < ApplicationController

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

end

**routes**
  devise_for :users, 
  resources :users, :only => [:show]

Upvotes: 1

nathan
nathan

Reputation: 5733

Ryan Bates has a RailsCast that explains how to do this. Essentially, you make use of nested attributes for the models.

Upvotes: 2

Related Questions