class ProfileQuestionsController

Public Instance Methods

edit() click to toggle source

Edit profile Information through profile questions appearing at the top of the page.

# File app/controllers/profile_questions_controller.rb, line 4
def edit
  @step = next_profile_question(params['step'].to_i+1) #next empty field from where user has skipped.
  if @step && (@step == 'complete') # if the skipped field is the only empty one.
    @step = 'complete'
  end
  unless @step == 'complete' #if its not the last field
    respond_to do |format|
      format.js {render 'skip'}
    end
  else
    redirect_via_turbolinks_to dashboard_path
  end
end
update() click to toggle source

Update profile Information through profile questions

# File app/controllers/profile_questions_controller.rb, line 19
def update
  if current_user.update_attributes(user_params)
    @step =  next_profile_question(User::PROFILE_QUESTION.rindex(params['step']))
    respond_to do |format|
      unless @step.blank? || @step == 'complete'
        format.js { render 'update'}
      else
        format.js {redirect_to dashboard_path}
      end
    end
  else
    respond_to do |format|
      format.js { render template: "profile_questions/edit", locals: {partial_name: params[:step].gsub(':', '/')}, within: '#profile_questions' }
    end
  end


end