Sha256: 89b84a2715810b5ac1b11472f28e95b7dd4a0443567c8fcd567540ae7bb54c92

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

module SwitchUserHelper
  def switch_user_select
    if Rails.env == "development"
      if current_user
        options = "<option value="">Guest</option>"
        options += options_from_collection_for_select(User.all, :id, :email, current_user.id)
      else
        options = "<option selected='selected' value="">Guest</option>"
        options += options_from_collection_for_select(User.all, :id, :email)
      end
      select_tag "switch_user_id", options.html_safe, 
                 :onchange => "location.href = '/switch_user?user_id=' + encodeURIComponent(this.options[this.selectedIndex].value)"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
switch_user-0.1.1 app/helpers/switch_user_helper.rb