Module: Sinatra::UserConfigurationHandler

Extended by:
Hexacta
Defined in:
lib/sinatra/handlers/user_configurations.rb

Constant Summary

Constants included from Hexacta

Hexacta::GEM_FILE_DIR

Instance Method Summary collapse

Methods included from Hexacta

copy_all_files, copy_dir_structure, copy_file, gem_path, setup_dir

Instance Method Details

#enable_user_configurationObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sinatra/handlers/user_configurations.rb', line 6

def enable_user_configuration
  p "Enabling user configurations..."

  get '/user/configuration' do
    user = authenticated(User)
    slim :'users/configuration', locals: { :user => user }
  end

  post '/user/configuration' do
    user_configuration_params = params.select { |attribute| UserConfiguration.columns.include?(attribute.to_sym) }
    user_configuration = UserConfiguration.find_or_create(:user_id => authenticated(User).id)
    user_configuration.update_fields(user_configuration_params, UserConfiguration.columns, :missing => :skip)
    redirect back
  end

end