Fixed Models & Migrations for setting custom IDs

This commit is contained in:
2016-01-07 20:48:14 -05:00
parent 5d04efe29c
commit 7b0538a043
7 changed files with 36 additions and 10 deletions

View File

@@ -12,6 +12,7 @@ class QboCustomers < ActiveRecord::Base
unloadable
has_many :issues
attr_accessible :name
validates_presence_of :id, :name
def self.update_all
qbo = Qbo.first
@@ -20,6 +21,7 @@ class QboCustomers < ActiveRecord::Base
# Update the customer table
service.all.each { |customer|
qbo_customer = QboCustomers.find_or_create_by(id: customer.id)
qbo_customer.id = customer.id
qbo_customer.name = customer.display_name
qbo_customer.save!
}

View File

@@ -11,6 +11,7 @@
class QboEmployee < ActiveRecord::Base
unloadable
attr_accessible :name
validates_presence_of :id, :name
def self.update_all
qbo = Qbo.first
@@ -19,7 +20,8 @@ class QboEmployee < ActiveRecord::Base
# Update the item table
service.all.each { |employee|
qbo_employee = QboEmployee.find_or_create_by(id: employee.id)
qbo_employee.name = employee.display_name
qbo_employee.name = employee.display_name
qbo_employee.id = employee.id
qbo_employee.save!
}
end

View File

@@ -11,6 +11,7 @@
class QboItem < ActiveRecord::Base
unloadable
attr_accessible :name
validates_presence_of :id, :name
def self.update_all
qbo = Qbo.first
@@ -20,6 +21,7 @@ class QboItem < ActiveRecord::Base
service.all.each { |item|
qbo_item = QboItem.find_or_create_by(id: item.id)
qbo_item.name = item.name
qbo_item.id = item.id
qbo_item.save!
}
end

View File

@@ -11,14 +11,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-->
<body>
<h1> Redmine Quickbooks</h1>
Customer Count: <%= @qbo_customer_count %>
Item Count: <%= @qbo_item_count %>
Employee Count: <%= @qbo_employee_count %>
<p>Customer Count: <%= @qbo_customer_count %></p>
<p>Item Count: <%= @qbo_item_count %></p>
<p>Employee Count: <%= @qbo_employee_count %></P>
<br/>
<br/>
<%= link_to "Sync", qbo_sync_path %>
</body>

View File

@@ -10,7 +10,8 @@
class CreateQboCustomers < ActiveRecord::Migration
def change
create_table :qbo_customers do |t|
create_table :qbo_customers, id: false do |t|
t.integer :id, :options => 'PRIMARY KEY'
t.string :name
end
end

View File

@@ -1,6 +1,17 @@
#The MIT License (MIT)
#
#Copyright (c) 2016 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class CreateQboItems < ActiveRecord::Migration
def change
create_table :qbo_items do |t|
create_table :qbo_items, id: false do |t|
t.integer :id, :options => 'PRIMARY KEY'
t.string :name
end
end

View File

@@ -1,6 +1,17 @@
#The MIT License (MIT)
#
#Copyright (c) 2016 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class CreateQboEmployees < ActiveRecord::Migration
def change
create_table :qbo_employees do |t|
create_table :qbo_employees, id: false do |t|
t.integer :id, :options => 'PRIMARY KEY'
t.string :name
end
end