Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gem for Percentage of Completion of Profile in Rails

I'm looking for a good gem to handle managing the "percentage of completion" of a signup workflow. Basically, my application allows a user to register with only an email and password then has a LinkedIn style percent indicator that increases as fields such as birthday and gender are added. Does a good gem exist for helping to setup a flow like this?

Thanks!

like image 454
Stussa Avatar asked Jun 01 '11 05:06

Stussa


3 Answers

here's a demo for a very simple (and lame) solution:

in you model, create an array with fields to complete, plus an integer field to store current status, for example:

class User < AR::Base
  PROFILE_COMPLETENESS = %w[email, website_url, personal-info, etc ]

  before_update :update_profile_progress, :if => Proc.new {|u| u.progress_status < 100}

  private
  def update_profile_progress
    progress = 0
    PROFILE_COMPLETENESS.each do |field|
      progress += 1 unless field.blank?
    end
    self.progress_status = (progress / PROFILE_COMPLETENESS * 100).to_i
  end
end

this way, everytime a user updates it's profile, percentage is updated (only if is lower than 100%).

maybe there're better solutions, this is just a possible approach to the problem ;)

like image 197
Andrea Pavoni Avatar answered Oct 18 '22 14:10

Andrea Pavoni


I guess completeness-fu is what you are looking for

like image 22
rubish Avatar answered Oct 18 '22 12:10

rubish


I wouldnt use a gem for this. Why don't you create a percent complete on your user profile and use that to graph the percent complete in the profile page. After the user adds the attribute for the first time simple add the desired number of points to the scale. You can also use some checks in your user model to ensure that the scale stays at or below 100 so you dont have any odd bugs.

like image 3
Devin M Avatar answered Oct 18 '22 14:10

Devin M