Module: MuckUsersHelper
- Defined in:
- app/helpers/muck_users_helper.rb
Instance Method Summary collapse
- #active_class(user) ⇒ Object
-
#random_access_code(provided_by) ⇒ Object
Generates a new random access code.
- #signin_form(options = {}, &block) ⇒ Object
-
#signup_form(user, redirect_to = nil, options = {}, &block) ⇒ Object
Render a basic user registration form.
-
#signup_form_javascript ⇒ Object
Sign up javascript is not required but will add script to the sign up form which will make ajax calls that indicate to the user whether or not the login and email they choose have already been taken.
Instance Method Details
#active_class(user) ⇒ Object
44 45 46 47 48 49 50 |
# File 'app/helpers/muck_users_helper.rb', line 44 def active_class(user) if user.active? 'user-active' else 'user-inactive' end end |
#random_access_code(provided_by) ⇒ Object
Generates a new random access code. If provided_by is provided then the provided_by user will be attached to the access code as the providing user.
54 55 56 57 58 59 60 61 62 63 |
# File 'app/helpers/muck_users_helper.rb', line 54 def random_access_code(provided_by) access_code = AccessCode.new(:expires_at => 1.year.since) access_code.provided_by = provided_by access_code.unlimited = false access_code.use_limit = 1 access_code.uses = 0 access_code.code = AccessCode.random_code access_code.save! access_code end |
#signin_form(options = {}, &block) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/helpers/muck_users_helper.rb', line 29 def signin_form( = {}, &block) [:html] = {} if [:html].nil? [:title] = nil if [:title].blank? [:exclude_register_link] = false if [:exclude_register_link].blank? [:exclude_forgot_password_link] = false if [:exclude_forgot_password_link].blank? [:exclude_forgot_username_link] = false if [:exclude_forgot_username_link].blank? raw_block_to_partial('user_sessions/form', , &block) end |
#signup_form(user, redirect_to = nil, options = {}, &block) ⇒ Object
Render a basic user registration form
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/muck_users_helper.rb', line 4 def signup_form(user, redirect_to = nil, = {}, &block) [:html] = {} if [:html].nil? [:title] = nil if [:title].blank? [:subtitle] = nil if [:subtitle].blank? if(params[:access_code] || session[:access_code]) access_code = params[:access_code] || session[:access_code] session[:access_code] = access_code @access_code = AccessCode.find_by_code(access_code) if @access_code user.email = @access_code.sent_to if user else @access_code_not_found = true end end if params[:access_code].blank? @access_code_help = '<p id="access_code_help" class="attention">' + translate('muck.users.access_code_help', :access_request_anchor => %Q{<a class="fancy-access-request iframe" href="#{new_access_code_request_path}">}, :access_request_anchor_end => "</a>") + '<p>'.html_safe end raw_block_to_partial('users/signup_form', .merge(:user => user, :redirect_to => redirect_to), &block) end |
#signup_form_javascript ⇒ Object
Sign up javascript is not required but will add script to the sign up form which will make ajax calls that indicate to the user whether or not the login and email they choose have already been taken.
40 41 42 |
# File 'app/helpers/muck_users_helper.rb', line 40 def signup_form_javascript render :partial => 'users/signup_form_javascript' end |