uploading profile pictures works now

This commit is contained in:
nilsding 2014-12-29 11:21:43 +01:00
parent 501f039e7f
commit 678e03deed
2 changed files with 8 additions and 5 deletions

View File

@ -1,4 +1,6 @@
class UserController < ApplicationController
before_filter :authenticate_user!, only: %w(edit update)
def show
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
@answers = @user.answers.reverse_order.paginate(page: params[:page])
@ -9,14 +11,13 @@ class UserController < ApplicationController
end
def edit
authenticate_user!
end
def update
authenticate_user!
user_attributes = params.require(:user).permit(:display_name, :motivation_header, :website, :location, :bio)
user_attributes = params.require(:user).permit(:display_name, :profile_picture, :motivation_header, :website,
:location, :bio)
unless current_user.update_attributes(user_attributes)
flash[:error] = 'fork it'
flash[:error] = 'An error occurred. ;_;'
end
redirect_to edit_user_profile_path
end

View File

@ -4,10 +4,12 @@
= render 'layouts/messages'
.panel.panel-default
.panel-body
= bootstrap_form_for(current_user, url: {action: "edit"}, method: "patch") do |f|
= bootstrap_form_for(current_user, url: {action: "edit"}, :html => { :multipart => true }, method: "patch") do |f|
= f.text_field :display_name, label: "Your name"
= f.file_field :profile_picture
= f.text_field :motivation_header, label: "Motivation header", placeholder: 'Ask me anything!'
= f.text_field :website, label: "Website", placeholder: 'http://bad-dragon.com'