Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class OnboardingController < ApplicationController
- # TODO: This is the jankiest shit ever and needs to be made better ASAP
- before_filter :authenticate_user!, :done_is_done, :load_step, :load_heading_and_message
- OnboardingSteps = %w{ share music friends done }
- def index
- render :index, :layout => 'onboarding'
- end
- def magic
- case current_step
- when OnboardingSteps[0]
- story = Story.share_movie(current_user, params[:netflix_id], 'suggest')
- render :index and return if story.blank?
- set_step(next_step)
- when OnboardingSteps[1]
- if params[:lastfm_username].present?
- current_user.update_attributes(:lastfm_username => params[:lastfm_username])
- end
- render :index and return if current_user.authentications.rdio.blank? && current_user.lastfm_username.blank?
- set_step(next_step)
- when OnboardingSteps[2]
- if current_user.authentications.twitter && params[:send_tweet] == 'true'
- client = current_user.twitter
- client.update("stuff")
- end
- render :index and return if current_user.authentications.twitter.blank?
- set_step(next_step)
- end
- redirect_to onboarding_path
- end
- private
- def current_step
- set_step(OnboardingSteps.first) if current_user.onboarding_step.blank?
- current_user.onboarding_step
- end
- def set_step(step)
- current_user.update_attribute(:onboarding_step, step) if OnboardingSteps.include? step
- end
- def next_step
- OnboardingSteps[OnboardingSteps.index(current_step) + 1]
- end
- def load_step
- @current_step = current_step
- @current_step_index = OnboardingSteps.index(@current_step)
- end
- def load_heading_and_message
- @onboarding_heading, @onboarding_message = case current_step
- when OnboardingSteps[0]
- ["Welcome to MyZeus", "Take a minute and set up the best experience"]
- when OnboardingSteps[1]
- ["Looking great, now add music", "Wait until you see this"]
- when OnboardingSteps[2]
- ["Last step, find friends", "MyZeus is a lot more fun with friends"]
- end
- end
- def done_is_done
- redirect_to dashboard_path and return if current_step == 'done'
- end
- end
Add Comment
Please, Sign In to add comment