Created
December 22, 2011 05:40
-
-
Save anonymous/1509102 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Device < ActiveRecord::Base | |
validates :device_type_id, :presence => true | |
validates :device_status_id, :presence => true | |
validates :serial_number, :presence => true | |
belongs_to :device_type | |
belongs_to :device_status | |
has_one :device_test, :dependent => :destroy | |
has_one :device_location, :dependent => :destroy | |
has_many :device_problem_statuses, :through => :device_problem | |
has_many :device_problems, :order => 'created_at DESC', :dependent => :destroy | |
has_many :audits, :dependent => :destroy | |
accepts_nested_attributes_for :device_problems, :device_location, :device_test, :allow_destroy => true | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DeviceLocation < ActiveRecord::Base | |
belongs_to :device | |
belongs_to :location | |
has_one :patient | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoMethodError in Devices#locations | |
Showing /home/russellpruitt/projects/inventory/app/views/devices/locations.html.erb where line #3 raised: | |
undefined method `device' for #<ActiveRecord::Relation:0xa6d4fd4> | |
Extracted source (around line #3): | |
1: <h1>Devices for: <%= @location.location_name %></h1> | |
2: | |
3: <% @location.location_devices %> | |
4: <br /> | |
Rails.root: /home/russellpruitt/projects/inventory | |
Application Trace | Framework Trace | Full Trace | |
app/models/location.rb:21:in `location_devices' | |
app/views/devices/locations.html.erb:3:in `_app_views_devices_locations_html_erb__908324986_90032260' | |
Request | |
Parameters: | |
{"id"=>"1"} | |
Show session dump | |
Show env dump | |
Response | |
Headers: | |
None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Location < ActiveRecord::Base | |
validates :location_type_id, :presence => true | |
validates :location_name, :presence => true | |
validates :location_street1, :presence => true | |
validates :location_city, :presence => true | |
validates :location_state, :presence => true | |
validates :location_zip, :presence => true | |
validates :location_contact, :presence => true | |
validates :par_level_event, :presence => true | |
validates :par_level_mct, :presence => true | |
validates :alert_amount, :presence => true | |
belongs_to :location_type | |
belongs_to :practice | |
has_many :location_alert_contacts, :dependent => :destroy | |
has_many :device_locations | |
accepts_nested_attributes_for :device_locations, :location_type, :practice, :location_alert_contacts | |
def location_devices | |
DeviceLocation.Device.all | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment