Merge pull request #4674 from BrokenEagle/add-missing-associated-attributes
Add missing associated attributes
This commit is contained in:
@@ -35,8 +35,10 @@ class ApplicationController < ActionController::Base
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
model = options[0]&.delete(:model)
|
||||||
if subject.respond_to?(:includes) && (request.format.json? || request.format.xml?)
|
if subject.respond_to?(:includes) && (request.format.json? || request.format.xml?)
|
||||||
associations = ParameterBuilder.includes_parameters(params[:only], model_name)
|
model ||= model_name
|
||||||
|
associations = ParameterBuilder.includes_parameters(params[:only], model)
|
||||||
subject = subject.includes(associations)
|
subject = subject.includes(associations)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class EmailsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@email_addresses = authorize EmailAddress.visible(CurrentUser.user).paginated_search(params, count_pages: true)
|
@email_addresses = authorize EmailAddress.visible(CurrentUser.user).paginated_search(params, count_pages: true)
|
||||||
@email_addresses = @email_addresses.includes(:user)
|
@email_addresses = @email_addresses.includes(:user)
|
||||||
respond_with(@email_addresses)
|
respond_with(@email_addresses, model: "EmailAddress")
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|||||||
@@ -72,4 +72,8 @@ class EmailAddress < ApplicationRecord
|
|||||||
def verification_key
|
def verification_key
|
||||||
signed_id(purpose: "verify")
|
signed_id(purpose: "verify")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.available_includes
|
||||||
|
[:user]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,11 @@ class ForumTopicVisit < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.search(params)
|
def self.search(params)
|
||||||
q = search_attributes(params, :id, :created_at, :updated_at, :user, :forum_topic_id, :last_read_at)
|
q = search_attributes(params, :id, :created_at, :updated_at, :user, :forum_topic, :last_read_at)
|
||||||
q.apply_default_order(params)
|
q.apply_default_order(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.available_includes
|
||||||
|
[:forum_topic]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -168,8 +168,4 @@ class SavedSearch < ApplicationRecord
|
|||||||
def disable_labels=(value)
|
def disable_labels=(value)
|
||||||
user.update(disable_categorized_saved_searches: true) if value.to_s.truthy?
|
user.update(disable_categorized_saved_searches: true) if value.to_s.truthy?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.available_includes
|
|
||||||
[:user]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -150,4 +150,8 @@ class TagImplication < TagRelationship
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.available_includes
|
||||||
|
super + [:child_implications, :parent_implications]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ class UserEvent < ApplicationRecord
|
|||||||
q
|
q
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.available_includes
|
||||||
|
[:user, :user_session]
|
||||||
|
end
|
||||||
|
|
||||||
concerning :ConstructorMethods do
|
concerning :ConstructorMethods do
|
||||||
class_methods do
|
class_methods do
|
||||||
# Build an event but don't save it yet. The caller is expected to update the user, which will save the event.
|
# Build an event but don't save it yet. The caller is expected to update the user, which will save the event.
|
||||||
|
|||||||
Reference in New Issue
Block a user