Skip to content

Instantly share code, notes, and snippets.

@jacksonpires
Created April 25, 2017 10:54
Show Gist options
  • Save jacksonpires/d455ba280e46fb9a260bbc6a0d3de61d to your computer and use it in GitHub Desktop.
Save jacksonpires/d455ba280e46fb9a260bbc6a0d3de61d to your computer and use it in GitHub Desktop.
Fix Pay Method
diff --git a/app/controllers/sales_controller.rb b/app/controllers/sales_controller.rb
index b06d59c..c575dfb 100644
--- a/app/controllers/sales_controller.rb
+++ b/app/controllers/sales_controller.rb
@@ -78,6 +78,6 @@ class SalesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def sale_params
- params.require(:sale).permit(:date, :buyer, :discount, :pay_method_id, :seller_id, :product_id, :rmk)
+ params.require(:sale).permit(:date, :buyer, :discount, :paymethod_id, :seller_id, :product_id, :rmk)
end
end
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 6114a32..693cf6d 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -1,5 +1,5 @@
class Sale < ApplicationRecord
- belongs_to :pay_method
+ belongs_to :paymethod
belongs_to :seller
belongs_to :product
end
diff --git a/app/views/sales/_form.html.erb b/app/views/sales/_form.html.erb
index 388d0ad..bee704b 100644
--- a/app/views/sales/_form.html.erb
+++ b/app/views/sales/_form.html.erb
@@ -28,7 +28,7 @@
<div class="field">
<%= f.label :paymethod_id %>
- <%= collection_select(:sale, :pay_method_id, @paymethods_to_select,
+ <%= collection_select(:sale, :paymethod_id, @paymethods_to_select,
:id, :name) %>
</div>
diff --git a/app/views/sales/index.html.erb b/app/views/sales/index.html.erb
index 3660ecb..a3b945c 100644
--- a/app/views/sales/index.html.erb
+++ b/app/views/sales/index.html.erb
@@ -22,7 +22,7 @@
<td><%= sale.date %></td>
<td><%= sale.buyer %></td>
<td><%= sale.discount %></td>
- <td><%= sale.pay_method %></td>
+ <td><%= sale.paymethod %></td>
<td><%= sale.seller %></td>
<td><%= sale.product %></td>
<td><%= sale.rmk %></td>
diff --git a/app/views/sales/show.html.erb b/app/views/sales/show.html.erb
index 2718aab..47bf467 100644
--- a/app/views/sales/show.html.erb
+++ b/app/views/sales/show.html.erb
@@ -17,7 +17,7 @@
<p>
<strong>Paymethod:</strong>
- <%= @sale.pay_method %>
+ <%= @sale.paymethod %>
</p>
<p>
diff --git a/db/migrate/20170322151803_create_sales.rb b/db/migrate/20170322151803_create_sales.rb
index 8ddb320..a2e4715 100644
--- a/db/migrate/20170322151803_create_sales.rb
+++ b/db/migrate/20170322151803_create_sales.rb
@@ -4,7 +4,7 @@ class CreateSales < ActiveRecord::Migration[5.0]
t.datetime :date
t.string :buyer
t.float :discount
- t.references :pay_method, foreign_key: true
+ t.references :paymethod, foreign_key: true
t.references :seller, foreign_key: true
t.references :product, foreign_key: true
t.text :rmk
diff --git a/db/schema.rb b/db/schema.rb
index 9074e19..166ad85 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -47,13 +47,13 @@ ActiveRecord::Schema.define(version: 20170322151803) do
t.datetime "date"
t.string "buyer"
t.float "discount"
- t.integer "pay_method_id"
+ t.integer "paymethod_id"
t.integer "seller_id"
t.integer "product_id"
t.text "rmk"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.index ["pay_method_id"], name: "index_sales_on_pay_method_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["paymethod_id"], name: "index_sales_on_paymethod_id"
t.index ["product_id"], name: "index_sales_on_product_id"
t.index ["seller_id"], name: "index_sales_on_seller_id"
end
@rafaelBadan
Copy link

valeu! @jacksonpires

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment