mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-25 20:46:12 +10:00
Instead of doing this:
link_to(commit.id, project_commit_path(project, id: commit.id))
Note.create(noteable_id: commit.id, noteable_type: "Commit", ...)
It lets us do this:
link_to(commit.id, project_commit_path(project, commit))
Note.create(noteable: commit, ...)
36 lines
634 B
Ruby
36 lines
634 B
Ruby
# Provides an ActiveRecord-like interface to a model whose data is not persisted to a database.
|
|
module StaticModel
|
|
extend ActiveSupport::Concern
|
|
|
|
module ClassMethods
|
|
# Used by ActiveRecord's polymorphic association to set object_id
|
|
def primary_key
|
|
'id'
|
|
end
|
|
|
|
# Used by ActiveRecord's polymorphic association to set object_type
|
|
def base_class
|
|
self
|
|
end
|
|
end
|
|
|
|
# Used by AR for fetching attributes
|
|
#
|
|
# Pass it along if we respond to it.
|
|
def [](key)
|
|
send(key) if respond_to?(key)
|
|
end
|
|
|
|
def to_param
|
|
id
|
|
end
|
|
|
|
def persisted?
|
|
false
|
|
end
|
|
|
|
def destroyed?
|
|
false
|
|
end
|
|
end
|