Gem for Rails Profile Completion Percentage

I am looking for a good stone to manage the "percent completion" of the registration workflow. Basically, my application only allows the user to register with email and password, and then has a LinkedIn style percentage percentage that increases with the addition of fields like birthday and gender. Is there a good stone to help set up such a stream?

Thanks!

+6
source share
3 answers

I think completeness-fu is what you are looking for

+5
source

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

in your model, create an array with filled fields plus an entire field to store the current state, 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 

Thus, every time a user updates his profile, the percentage is updated (only if he is below 100%).

Perhaps there are better solutions, this is just a possible approach to the problem;)

+11
source

I would not use a gem for this. Why don't you create a percentage in your user profile and use this to display the percentage completed on the profile page. After the user first adds the attribute, simply add the desired number of points to the scale. You can also use some checks in your user model to ensure that the scale remains at or below 100 so that you don't have any odd errors.

+3
source

Source: https://habr.com/ru/post/889506/


All Articles