Created
October 25, 2013 15:42
-
-
Save mskeen/7156739 to your computer and use it in GitHub Desktop.
rails: use class_name - same model multiple times
This file contains 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 AirplaneClass < ActiveRecord::Base | |
attr_accessible :name, :description, :organization_id, :stations_attributes, | |
:ifr_certified, :currency_if_over_150, :min_hours_to_qualify, | |
:max_wind_limitation, :min_weight, :max_weight, :datapoints_attributes, | |
:cruise_performance_chart_id, :landing_distance_chart_id, | |
:takeoff_distance_chart_id | |
belongs_to :organization | |
has_many :airplanes | |
has_many :stations | |
has_many :rental_requests | |
has_many :datapoints | |
belongs_to :cruise_performance_chart, class_name: "Chart", foreign_key: "cruise_performance_chart_id" | |
belongs_to :landing_distance_chart, class_name: "Chart", foreign_key: "landing_distance_chart_id" | |
belongs_to :takeoff_distance_chart, class_name: "Chart", foreign_key: "takeoff_distance_chart_id" | |
accepts_nested_attributes_for :stations, allow_destroy: true | |
accepts_nested_attributes_for :datapoints, allow_destroy: true | |
validates :name, :presence => true, :uniqueness => {:scope => :organization_id} | |
default_scope order: "name" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment