Skip to content

Instantly share code, notes, and snippets.

@mailsonsoares
Created May 10, 2022 02:34
Show Gist options
  • Select an option

  • Save mailsonsoares/5457c190ccf923deec70a20f4a68533a to your computer and use it in GitHub Desktop.

Select an option

Save mailsonsoares/5457c190ccf923deec70a20f4a68533a to your computer and use it in GitHub Desktop.
# Models from existing tables
class YourIdealModelName < ActiveRecord::Base
self.table_name = 'actual_table_name'
self.primary_key = 'ID'
self.sequence_name = 'name_seq'
belongs_to :other_ideal_model,
:foreign_key => 'foreign_key_on_other_table'
has_many :some_other_ideal_models,
:foreign_key => 'foreign_key_on_this_table',
:primary_key => 'primary_key_on_other_table'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment