has_one :credit_card, dependent: :destroy # destroys the associated credit card
has_one :credit_card, dependent: :nullify # updates the associated records foreign
# key value to NULL rather than destroying it
has_one :last_comment, -> { order('posted_on') }, class_name: "Comment"
has_one :project_manager, -> { where(role: 'project_manager') }, class_name: "Person"
has_one :attachment, as: :attachable
has_one :boss, -> { readonly }
has_one :club, through: :membership
has_one :primary_address, -> { where(primary: true) }, through: :addressables, source: :addressable
has_one :credit_card, required: true
Code Example |
---|
Ruby :: ruby rails remove tmp/pids/server.pid |
Ruby :: ruby get classname |
Ruby :: rails ago |
Ruby :: parameterized scope rails code |
Ruby :: ruby find object identifier |
Ruby :: devise remove * sign up form |
Ruby :: elsif ruby |
Ruby :: ruby hash merge vs merge! |
Ruby :: ruby extract elements from array |
Ruby :: string uppercase ruby |
Ruby :: rollback specific migration rails |
R :: paste no space r |
R :: r remove rows where value is 0 |
R :: reverse row order dataframe R |
R :: r mean by group |
R :: exponent R |
R :: ggplot - blank title of axis |
R :: how to do logistic regression in r |
R :: ggplot2 black and white theme |
R :: remove all trailing whitspaces R |
R :: r number of blanks in the data |
R :: r as.numeric all columns except |
R :: how to change order in bar chart r |
R :: read xlsx in r |
R :: R: foreach multiple argument |
R :: Use regex to extract row in R (solution 1) |
R :: connect excel to r |
R :: why is only mean and max infinity in r |
R :: concatenate r |
Rust :: sort a vec<f32 rust |