| Class | ProfilesController |
| In: |
app/controllers/profiles_controller.rb
|
| Parent: | ApplicationController |
POST /profiles POST /profiles.xml
# File app/controllers/profiles_controller.rb, line 53
53: def create
54: @profile = Profile.new(params[:profile].merge(:user_id => current_user.id))
55:
56: respond_to do |format|
57: if @profile.save
58: save_profile_questions(@profile, params[:profile_question])
59: flash[:notice] = t 'profile.success'
60: format.html { redirect_to(@profile) }
61: format.xml { render :xml => @profile, :status => :created, :location => @profile }
62: else
63: @header = t('profile.new')
64: format.html { render :action => "edit" }
65: format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }
66: end
67: end
68: end
GET /profiles/1/edit
# File app/controllers/profiles_controller.rb, line 45
45: def edit
46: @header = t('profile.edit')
47: @profile = current_user.profile
48: # raise @profile.date_of_birth.inspect
49: end
GET /profiles GET /profiles.xml
# File app/controllers/profiles_controller.rb, line 12
12: def index
13: @profiles = Profile.all
14:
15: respond_to do |format|
16: format.html # index.html.erb
17: format.xml { render :xml => @profiles }
18: end
19: end
POST /profiles/language
# File app/controllers/profiles_controller.rb, line 90
90: def language
91: if locale = valid_locale(params[:id])
92: if logged_in?
93: if profile = current_user.profile
94: profile.update_attribute(:locale, locale)
95: else
96: Profile.create(:user_id => current_user.id, :locale => locale)
97: end
98: end
99: # start a new visit on locale change so that we can track finer grained
100: create_visit(locale)
101: I18n.locale = self.locale = locale
102: end
103: params[:q].to_i > 0 ? redirect_to(response_path(params[:q].to_i)) : redirect_back_or_default(:root)
104: end
GET /profiles/new GET /profiles/new.xml
# File app/controllers/profiles_controller.rb, line 35
35: def new
36: @profile = Profile.new
37: @header = t('profile.new')
38: respond_to do |format|
39: format.html { render :action => 'edit' }
40: format.xml { render :xml => @profile }
41: end
42: end
GET /profiles/1 GET /profiles/1.xml
# File app/controllers/profiles_controller.rb, line 23
23: def show
24: @profile = current_user.profile(:include => :profile_questions)
25: @limit = LAST_ITEMS_LIMIT
26: @items = fetch_user_items(false)
27: respond_to do |format|
28: format.html # show.html.erb
29: format.xml { render :xml => @profile }
30: end
31: end
PUT /profiles/1 PUT /profiles/1.xml
# File app/controllers/profiles_controller.rb, line 72
72: def update
73: @profile = current_user.profile
74:
75: respond_to do |format|
76: if @profile.update_attributes(params[:profile])
77: save_profile_questions(@profile, params[:profile_question])
78: flash[:notice] = t('profile.success')
79: format.html { redirect_to(@profile) }
80: format.xml { head :ok }
81: else
82: @header = t('profile.edit')
83: format.html { render :action => "edit" }
84: format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }
85: end
86: end
87: end