diff --git a/Gemfile b/Gemfile index 660532a..449e05c 100644 --- a/Gemfile +++ b/Gemfile @@ -25,6 +25,8 @@ gem 'cancancan' gem 'purecss-rails' # Use datatables gem 'jquery-datatables-rails', '~> 3.3.0' +# Use Select2 for selecting users +gem 'select2-rails' # Use jquery as the JavaScript library diff --git a/Gemfile.lock b/Gemfile.lock index f24eedc..a81e6df 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -197,6 +197,8 @@ GEM sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) + select2-rails (3.5.9.3) + thor (~> 0.14) spring (1.3.6) sprockets (3.3.4) rack (~> 1.0) @@ -253,6 +255,7 @@ DEPENDENCIES rspec-rails sass-rails (~> 5.0) sdoc (~> 0.4.0) + select2-rails spring sqlite3 turbolinks diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 6a254ee..ca57169 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -13,5 +13,11 @@ //= require jquery //= require jquery_ujs //= require dataTables/jquery.dataTables +//= require select2 //= require turbolinks //= require_tree . + +$(document).ready(function() { + $(".select2-selector").select2(); +}); + diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 28c16f8..98af4c5 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -12,5 +12,6 @@ * *= require_tree . *= require dataTables/jquery.dataTables + *= require select2 *= require_self */ diff --git a/app/views/transactions/new.html.erb b/app/views/transactions/new.html.erb index 2621d4c..e977f40 100644 --- a/app/views/transactions/new.html.erb +++ b/app/views/transactions/new.html.erb @@ -1,3 +1,7 @@ -Hello, new transaction +<%= form_for @transaction do |f| %> + <%= f.select :creditor, User.all, {}, { class: 'select2-selector' } %> + <%= f.number_field :amount %> + <%= f.submit "Send it!" %> +<% end %>