mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Removed unsed code & cleaned up comments
This commit is contained in:
@@ -15,12 +15,9 @@ class Vehicle < ActiveRecord::Base
|
|||||||
belongs_to :customer
|
belongs_to :customer
|
||||||
has_many :issues, :foreign_key => 'vehicles_id'
|
has_many :issues, :foreign_key => 'vehicles_id'
|
||||||
|
|
||||||
#attr_accessible :year, :make, :model, :customer_id, :notes, :vin
|
|
||||||
|
|
||||||
validates_presence_of :customer
|
validates_presence_of :customer
|
||||||
validates :vin, uniqueness: true
|
validates :vin, uniqueness: true
|
||||||
before_save :decode_vin
|
before_save :decode_vin
|
||||||
#after_find :get_details
|
|
||||||
|
|
||||||
self.primary_key = :id
|
self.primary_key = :id
|
||||||
|
|
||||||
@@ -34,35 +31,12 @@ class Vehicle < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns the raw JSON details from EMUNDS
|
# returns the raw JSON details from NHTSA
|
||||||
def details
|
def details
|
||||||
get_details if @details.nil?
|
get_details if @details.nil?
|
||||||
return @details
|
return @details
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns the style of the vehicle
|
|
||||||
def style
|
|
||||||
get_details if @details.nil?
|
|
||||||
begin
|
|
||||||
return @details.trim if @details
|
|
||||||
rescue
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# returns the drive of the vehicle i.e. 2 wheel, 4 wheel, ect.
|
|
||||||
def drive
|
|
||||||
#todo fix this
|
|
||||||
#return @details.drive_type if @details
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
# returns the number of doors of the vehicle
|
|
||||||
#def doors
|
|
||||||
# get_details if @details.nil?
|
|
||||||
# return @details.doors if @details
|
|
||||||
#end
|
|
||||||
|
|
||||||
# Force Upper Case for make numbers
|
# Force Upper Case for make numbers
|
||||||
def make=(val)
|
def make=(val)
|
||||||
# The to_s is in case you get nil/non-string
|
# The to_s is in case you get nil/non-string
|
||||||
@@ -75,9 +49,8 @@ class Vehicle < ActiveRecord::Base
|
|||||||
write_attribute(:model, val.to_s.titleize)
|
write_attribute(:model, val.to_s.titleize)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Force Upper Case for VIN numbers
|
# Force Upper Case & strip VIN of all illegal chars (for barcode scanner)
|
||||||
def vin=(val)
|
def vin=(val)
|
||||||
#strip VIN of all illegal chars (for barcode scanner)
|
|
||||||
val = val.to_s.upcase.gsub(/[^A-HJ-NPR-Za-hj-npr-z\d]+/,"")
|
val = val.to_s.upcase.gsub(/[^A-HJ-NPR-Za-hj-npr-z\d]+/,"")
|
||||||
write_attribute(:vin, val)
|
write_attribute(:vin, val)
|
||||||
end
|
end
|
||||||
@@ -106,7 +79,7 @@ class Vehicle < ActiveRecord::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# init method to pull JSON details from Edmunds
|
# init method to pull JSON details from NHTSA
|
||||||
def get_details
|
def get_details
|
||||||
if self.vin?
|
if self.vin?
|
||||||
#validate the vin before calling a remote server
|
#validate the vin before calling a remote server
|
||||||
|
|||||||
Reference in New Issue
Block a user