Class: Comment
Overview
The other side of Article#comments: what spin run gen writes for a
comments table with t.references :article (an article_id column and
a foreign key to articles). It has the same finders as Article, through
CommentRelation.
Instance Attribute Summary collapse
#id
Class Method Summary
collapse
Instance Method Summary
collapse
-
#article ⇒ Article?
belongs_to, from the foreign key article_id: the article, or nil when there is none.
#==, after_create, after_destroy, after_save, after_update, #as_json, #attributes, before_create, before_destroy, before_save, before_update, before_validation, #destroy, #errors, #new_record?, #persisted?, #reload, #save, #save!, #to_json, #to_param, #update, #valid?, validates
Instance Attribute Details
#article_id ⇒ Integer
The foreign key; 0 until set (references columns are null: false).
362
363
364
|
# File 'docs/api/stubs/generated_app.rb', line 362
def article_id
@article_id
end
|
#body ⇒ String?
357
358
359
|
# File 'docs/api/stubs/generated_app.rb', line 357
def body
@body
end
|
353
354
355
|
# File 'docs/api/stubs/generated_app.rb', line 353
def
@commenter
end
|
Class Method Details
344
|
# File 'docs/api/stubs/generated_app.rb', line 344
def self.all = CommentRelation.new("comments")
|
349
|
# File 'docs/api/stubs/generated_app.rb', line 349
def self.where(conditions) = all.where(conditions)
|
Instance Method Details
belongs_to, from the foreign key article_id: the article, or nil
when there is none. A fresh query on every call. When a column already
has the name, the reader is <stem>_as_<column> (author_as_author_id).
369
|
# File 'docs/api/stubs/generated_app.rb', line 369
def article = Article.find_by(id: @article_id)
|