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!
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 ;)
I guess completeness-fu is what you are looking for
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With