diff --git a/app/controllers/pay_controller.rb b/app/controllers/pay_controller.rb index d03b21c..b7ca2d5 100644 --- a/app/controllers/pay_controller.rb +++ b/app/controllers/pay_controller.rb @@ -4,9 +4,23 @@ class PayController < ApplicationController end def update_dd_info + msg = false + pay = Pay.new( + :bank_account_num => params[:bank_account_num], + :bank_routing_num => params[:bank_routing_num], + :percent_of_deposit => params[:dd_percent] + ) + pay.user_id = current_user.user_id + msg = true if pay.save! respond_to do |format| - format.json {render :json => {:hello => :world} } + format.json {render :json => {:msg => :world} } end end + def show + respond_to do |format| + format.json { render :json => {:user => current_user.pay.as_json} } + end + end + end diff --git a/app/models/pay.rb b/app/models/pay.rb index 1e465e1..a1ee601 100644 --- a/app/models/pay.rb +++ b/app/models/pay.rb @@ -1,5 +1,25 @@ class Pay < ActiveRecord::Base + + # mass-assignable attributes attr_accessible :bank_account_num, :bank_routing_num, :percent_of_deposit + + # Associations belongs_to :user + # Validations + validates :bank_account_num, presence: true + validates :bank_routing_num, presence: true + validates :percent_of_deposit, presence: true + + # actions + before_save :encrypt_bank_account_num + + def as_json + super(only: [:bank_account_num, :bank_routing_num, :percent_of_deposit]) + end + + def encrypt_bank_account_num + self.bank_account_num = Encryption.encrypt_sensitive_value(self.bank_account_num) + end + end diff --git a/app/views/pay/index.html.erb b/app/views/pay/index.html.erb index aa5b822..c9bb2e9 100644 --- a/app/views/pay/index.html.erb +++ b/app/views/pay/index.html.erb @@ -63,149 +63,126 @@ - -
-
-
-
-
- Deletable Table Row -
-
-
- - - - - - - - - - - - - - -
- Bank Account Number - - Bank Routing Number - - Percentage of Deposit - - Actions -
- 1 - - Srinu - - Active - - + + + +
+
+
+ + +
+
+ Accounts +
+
+ +
+
+ + + + + + + + + + + - + + --> + +
+ Bank Account Number + + Bank Routing Number + + Percentage of Deposit + + Action +
+
+
+
+
+
+
+
+ +<%= javascript_include_tag "jquery.dataTables.js" %> + \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 39b0f53..9ff11cf 100755 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -28,6 +28,9 @@ Railsgoat::Application.configure do # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Tired of caching causing issues + config.middleware.delete Rack::ETag # Do not compress assets config.assets.compress = false