Skip to content

Instantly share code, notes, and snippets.

@mecampbellsoup
Created February 23, 2015 00:48
Show Gist options
  • Select an option

  • Save mecampbellsoup/2c2d8c8a08b24481540e to your computer and use it in GitHub Desktop.

Select an option

Save mecampbellsoup/2c2d8c8a08b24481540e to your computer and use it in GitHub Desktop.
class FlybladeController < ApplicationController
def check_terms_of_service_version
return if request.path == edit_user_path(current_user)
version = Flyblade::TermsOfServicePolicy.current_version
unless current_user.terms_of_service_version == version
return redirect_to edit_user_path(current_user)
end
end
end
@creeefs
Copy link
Copy Markdown

creeefs commented Feb 23, 2015

I think you can omit line 3 if you just skip the method for the edit user action. skip_before_action :check_terms_of_service_version, only: [:edit]

@creeefs
Copy link
Copy Markdown

creeefs commented Feb 23, 2015

What do you think of the following?

  • Add validates_acceptance_of: terms_of_service to User
  • Add terms_of_service field to the new user form
  • When a new user is saved, persist the terms of service based on Flyblade::TermsOfServicePolicy.current_version
  • Have a before_action that checks the user has accepted most recent terms of service (if not, redirect to standalone terms of service form)

@mecampbellsoup
Copy link
Copy Markdown
Author

skip_before_action :check_terms_of_service_version, only: [:edit, :update]

Needed on update as well right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment