Created
          March 14, 2012 13:19 
        
      - 
      
 - 
        
Save Surgeon/2036399 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <%= semantic_form_for @user do |f| %> | |
| <%= f.inputs :name, :password, :sex, :birthday, :about, :skype, :facebook, :twitter, :livejournal %> | |
| <%= f.actions :submit, :cancel %> | |
| <% end %> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class User < ActiveRecord::Base | |
| # Include default devise modules. Others available are: | |
| # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable | |
| include Likeable::UserMethods | |
| devise :database_authenticatable, :registerable, | |
| :recoverable, :rememberable, :trackable, :validatable, :omniauthable | |
| has_many :advices, :dependent => :destroy | |
| has_many :answers, :dependent => :destroy | |
| has_many :comments, :dependent => :destroy | |
| has_many :questions, :dependent => :destroy | |
| has_many :trips, :dependent => :destroy | |
| has_many :authentications, :dependent => :destroy | |
| belongs_to :account | |
| # Setup accessible (or protected) attributes for your model | |
| attr_accessible :email, :password, :password_confirmation, :remember_me, :admin, | |
| :name, :birthday, :sex, :about, :skype, :facebook, :twitter, :livejournal | |
| def apply_omniauth(omniauth) | |
| authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid']) | |
| end | |
| def password_required? | |
| (authentications.empty? || !password.blank?) && super | |
| end | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class UsersController < ApplicationController | |
| def update | |
| @user = current_user | |
| respond_to do |format| | |
| if @user.update_attributes(params[:user]) | |
| format.html { redirect_to(@user) } | |
| else | |
| format.html { render :action => "edit" } | |
| end | |
| end | |
| end | |
| def show | |
| @user = current_user | |
| end | |
| def edit | |
| @user = current_user | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment