summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-11-14 21:19:58 -0700
committermo khan <mo@mokhan.ca>2015-11-14 21:19:58 -0700
commitd311e696b9689c8c8eaf8eb13dd6773243eba2c8 (patch)
treef812771f88d02e4d9fcf4073f3026dc4c5b2ff3e /app
parentf28ddb69d7cca6bce073d82391bca5a323db0d82 (diff)
remove redundant code from profiles controller.
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/views/google_sync_button.js.coffee1
-rw-r--r--app/controllers/profiles_controller.rb30
-rw-r--r--app/views/profiles/edit.html.erb8
3 files changed, 14 insertions, 25 deletions
diff --git a/app/assets/javascripts/views/google_sync_button.js.coffee b/app/assets/javascripts/views/google_sync_button.js.coffee
index 3f0c7d5..b60b0e0 100644
--- a/app/assets/javascripts/views/google_sync_button.js.coffee
+++ b/app/assets/javascripts/views/google_sync_button.js.coffee
@@ -14,4 +14,3 @@ Stronglifters.GoogleSyncButton = Ractive.extend
@_drive ||= new Stronglifters.GoogleDrive
client_id: @get('client_id')
drive_upload_path: @get('drive_upload_path')
-
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index 185b218..9abd1b4 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -1,33 +1,25 @@
class ProfilesController < ApplicationController
-
def show
@user = User.find_by(username: params[:id])
@profile = @user.profile
@program = Program.stronglifts
end
-
+
def edit
- @user = @current_user
- @profile = @user.profile
+ @profile = @current_user.profile
@program = Program.stronglifts
end
-
+
def update
- if @current_user
- @profile = @current_user.profile
- @profile.update_attributes(profile_params)
- flash[:notice] = t("profiles.edit.profile_update_success")
- redirect_to profile_path(@profile)
- else
- flash[:notice] = t("profiles.edit.profile_update_error")
- render 'edit'
- end
+ profile = @current_user.profile
+ profile.update_attributes(profile_params)
+ flash[:notice] = t("profiles.edit.profile_update_success")
+ redirect_to profile_path(profile)
end
-
+
private
- def profile_params
- params.require(:profile).permit(:gender, :social_tolerance)
- end
-
+ def profile_params
+ params.require(:profile).permit(:gender, :social_tolerance)
+ end
end
diff --git a/app/views/profiles/edit.html.erb b/app/views/profiles/edit.html.erb
index 4f78226..af8e2c3 100644
--- a/app/views/profiles/edit.html.erb
+++ b/app/views/profiles/edit.html.erb
@@ -1,8 +1,7 @@
<div class="row">
-
<div class="small-12 columns text-center">
- <%= gravatar_for(@user, size: 128) %>
- <h1><%= @user.username %></h1>
+ <%= gravatar_for(@current_user, size: 128) %>
+ <h1><%= @current_user.username %></h1>
<%= form_for(@profile, method: :patch) do |f| %>
<fieldset>
<legend><%= t("profiles.edit.gender.gender") %></legend>
@@ -25,5 +24,4 @@
<%= f.submit t("profiles.edit.save"), class: "button" %>
<% end %>
</div>
-
-</div> \ No newline at end of file
+</div>