Class: IshManager::UserProfilesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshManager::UserProfilesController
- Defined in:
- app/controllers/ish_manager/user_profiles_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/ish_manager/user_profiles_controller.rb', line 49 def create @user = User.find_or_create_by( :email => params[:profile][:email] ) @user.password ||= (0...12).map { rand(100) }.join @user_profile = Ish::UserProfile.new params[:profile].permit! :create, @user_profile if params[:photo] photo = Photo.new :photo => params[:photo] @user_profile.profile_photo = photo end if !@user.save raise "cannot save profile.user: #{@user.errors.} profile errors: #{@user_profile.errors.}" end if @user_profile.save flash[:notice] = "Created profile" else flash[:alert] = "Cannot create profile: #{@user_profile.errors.}" end redirect_to :action => :index end |
#edit ⇒ Object
16 17 18 19 |
# File 'app/controllers/ish_manager/user_profiles_controller.rb', line 16 def edit @profile = Ish::UserProfile.find params[:id] :edit, @profile end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/ish_manager/user_profiles_controller.rb', line 6 def index @user_profiles = Ish::UserProfile.all :index, Ish::UserProfile end |
#new ⇒ Object
44 45 46 47 |
# File 'app/controllers/ish_manager/user_profiles_controller.rb', line 44 def new @profile = Ish::UserProfile.new :new, @profile end |
#show ⇒ Object
11 12 13 14 |
# File 'app/controllers/ish_manager/user_profiles_controller.rb', line 11 def show @user_profile = Ish::UserProfile.find params[:id] :show, @user_profile end |
#update ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/ish_manager/user_profiles_controller.rb', line 21 def update @profile = Ish::UserProfile.find params[:id] :update, @profile if params[:photo] photo = Photo.new :photo => params[:photo] @profile.profile_photo = photo end flag = @profile.update_attributes params[:profile].permit! if flag flash[:notice] = "Updated profile #{@profile.email}" else flash[:alert] = "Cannot update profile: #{@profile.errors.}" end if params[:redirect_to] redirect_to params[:redirect_to] else redirect_to :action => :index end end |