mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-29 05:18:49 +01:00
updating preferences on user and prefs model work. also add date_format picker
This commit is contained in:
parent
89ec9898a3
commit
555311b681
12 changed files with 945 additions and 1010 deletions
|
|
@ -1,23 +1,31 @@
|
|||
class PreferencesController < ApplicationController
|
||||
|
||||
|
||||
def index
|
||||
@page_title = t('preferences.page_title')
|
||||
@prefs = current_user.prefs
|
||||
@user = current_user
|
||||
end
|
||||
|
||||
def edit
|
||||
@page_title = t('preferences.page_title_edit')
|
||||
@prefs = current_user.prefs
|
||||
end
|
||||
|
||||
def update
|
||||
@prefs = current_user.prefs
|
||||
@user = current_user
|
||||
user_updated = current_user.update_attributes(params['user'])
|
||||
prefs_updated = current_user.preference.update_attributes(params['prefs'])
|
||||
if user_updated && prefs_updated
|
||||
if (user_updated && prefs_updated)
|
||||
notify :notice, "Preferences updated"
|
||||
redirect_to :action => 'index'
|
||||
else
|
||||
render :action => 'edit'
|
||||
msg = "Preferences could not be updated: "
|
||||
msg += "User model errors; " unless user_updated
|
||||
msg += "Prefs model errors; " unless prefs_updated
|
||||
notify :warning, msg
|
||||
render 'index'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def render_date_format
|
||||
format = params[:date_format]
|
||||
render :text => l(Date.today, :format => format)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue