diff --git a/app/controllers/characters_controller.rb b/app/controllers/characters_controller.rb index 85f2bbcc..41011655 100644 --- a/app/controllers/characters_controller.rb +++ b/app/controllers/characters_controller.rb @@ -10,6 +10,9 @@ class CharactersController < ContentController def content_param_list [ #todo remove all these (for all pages) now that we use custom attributes for them all (minus links) + # all but + #custom_attribute_values: [:name, :value], + :universe_id, :user_id, :name, :age, :role, :gender, :age, :archetype, :height, :weight, :haircolor, :facialhair, :eyecolor, :skintone, :bodytype, :identmarks, :hairstyle, diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 7f3496a5..cc622df3 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -108,7 +108,7 @@ class ContentController < ApplicationController # Don't set name fields on content that doesn't have a name field #todo abstract this (and the one in update) to a function - unless [AttributeCategory, AttributeField, Attribute].map(&:name).include?(@content.class.name) + unless [AttributeCategory, AttributeField, Attribute].map(&:name).include?(@content.class.name) && [nil, ''].include?(@content.name) @content.name = @content.name_field_value || "Untitled" end @@ -116,6 +116,7 @@ class ContentController < ApplicationController 'content_type': content_type.name }) if Rails.env.production? + # todo look at this code smell for collab @content.user = current_user if @content.update_attributes(content_params) cache_params = {} diff --git a/app/controllers/deities_controller.rb b/app/controllers/deities_controller.rb index d41ac424..283f4dfa 100644 --- a/app/controllers/deities_controller.rb +++ b/app/controllers/deities_controller.rb @@ -24,7 +24,8 @@ class DeitiesController < ContentController deity_relics_attributes: [:id, :relic_id, :_destroy], deity_abilities_attributes: [:id, :ability_id, :_destroy], deity_related_towns_attributes: [:id, :related_town_id, :_destroy], - deity_related_landmarks_attributes: [:id, :related_landmark_id, :_destroy] + deity_related_landmarks_attributes: [:id, :related_landmark_id, :_destroy], + custom_attribute_values: [:name, :value] ] end end diff --git a/app/controllers/governments_controller.rb b/app/controllers/governments_controller.rb index ef1ad89e..b2f56d68 100644 --- a/app/controllers/governments_controller.rb +++ b/app/controllers/governments_controller.rb @@ -17,7 +17,8 @@ class GovernmentsController < ContentController government_political_figures_attributes: [:id, :political_figure_id, :_destroy], government_items_attributes: [:id, :item_id, :_destroy], government_technologies_attributes: [:id, :technology_id, :_destroy], - government_creatures_attributes: [:id, :creature_id, :_destroy] + government_creatures_attributes: [:id, :creature_id, :_destroy], + custom_attribute_values: [:name, :value] ] end end diff --git a/app/controllers/planets_controller.rb b/app/controllers/planets_controller.rb index 8a355609..e777dc62 100644 --- a/app/controllers/planets_controller.rb +++ b/app/controllers/planets_controller.rb @@ -25,7 +25,8 @@ class PlanetsController < ContentController planet_groups_attributes: [:id, :group_id, :_destroy], planet_languages_attributes: [:id, :language_id, :_destroy], planet_towns_attributes: [:id, :town_id, :_destroy], - planet_nearby_planets_attributes: [:id, :nearby_planet_id, :_destroy] + planet_nearby_planets_attributes: [:id, :nearby_planet_id, :_destroy], + custom_attribute_values: [:name, :value] ] end end diff --git a/app/controllers/technologies_controller.rb b/app/controllers/technologies_controller.rb index a6b9c18f..47171090 100644 --- a/app/controllers/technologies_controller.rb +++ b/app/controllers/technologies_controller.rb @@ -18,7 +18,8 @@ class TechnologiesController < ContentController technology_magics_attributes: [:id, :magic_id, :_destroy], technology_parent_technologies_attributes: [:id, :parent_technology_id, :_destroy], technology_child_technologies_attributes: [:id, :child_technology_id, :_destroy], - technology_related_technologies_attributes: [:id, :related_technology_id, :_destroy] + technology_related_technologies_attributes: [:id, :related_technology_id, :_destroy], + custom_attribute_values: [:name, :value] ] end end diff --git a/app/services/permission_service.rb b/app/services/permission_service.rb index b67f416a..d94dde56 100644 --- a/app/services/permission_service.rb +++ b/app/services/permission_service.rb @@ -30,7 +30,7 @@ class PermissionService < Service end def self.content_has_no_containing_universe?(content:) - content.universe.nil? + content.universe_field_value.nil? end def self.user_is_on_premium_plan?(user:)