Sha256: 82905e6add6e0e0054d58e76e3e8b4f71aeb60cad0f15e6d378f8cad92399eb9

Contents?: true

Size: 1.24 KB

Versions: 29

Compression:

Stored size: 1.24 KB

Contents

class Wco::ProfilesController < Wco::ApplicationController

  def create
    @profile = Wco::Profile.new params[:profile].permit!
    authorize! :create, @profile
    if @profile.save
      flash_notice @profile
      redirect_to action: :index
    else
      flash_alert @profile
      render action: 'new'
    end
  end

  def edit
    @profile = Wco::Profile.find params[:id]
    authorize! :update, @profile
  end

  def index
    @profiles = Wco::Profile.all
    authorize! :index, Wco::Profile
    if params[:q]
      q = URI.decode(params[:q])
      @profiles = @profiles.where({ email: /#{q}/i })
    end
  end

  def new
    @new_profile = Wco::Profile.new
    authorize! :new, @new_profile
  end

  def update
    @profile = Wco::Profile.find params[:id]
    authorize! :update, @profile

    # if params[:photo]
    #   photo = Photo.new :photo => params[:photo]
    #   @profile.profile_photo = photo
    # end

    flag = @profile.update params[:profile].permit!
    if flag
      flash_notice "Updated profile #{@profile.email}"
    else
      flash_alert "Cannot update profile: #{@profile.errors.full_messages}"
    end
    if params[:redirect_to]
      redirect_to params[:redirect_to]
    else
      redirect_to request.referrer
    end
  end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
wco_models-3.1.0.189 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.188 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.187 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.184 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.183 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.182 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.181 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.180 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.178 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.177 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.176 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.175 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.174 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.173 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.172 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.171 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.170 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.169 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.168 app/controllers/wco/profiles_controller.rb
wco_models-3.1.0.167 app/controllers/wco/profiles_controller.rb