diff --git a/Gemfile b/Gemfile index 54324097..c7c6fac9 100644 --- a/Gemfile +++ b/Gemfile @@ -76,6 +76,10 @@ gem 'csv' # Tech debt & hacks gem 'binding_of_caller' # see has_changelog.rb +group :development do + gem 'web-console' +end + group :production do gem 'rails_12factor' gem 'uglifier', '>= 1.3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 8b71f463..7c8e0496 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -490,6 +490,10 @@ GEM unicode-display_width (1.4.0) warden (1.2.7) rack (>= 1.0) + web-console (3.3.0) + activemodel (>= 4.2) + debug_inspector + railties (>= 4.2) webmock (3.4.2) addressable (>= 2.3.6) crack (>= 0.3.2) @@ -567,6 +571,7 @@ DEPENDENCIES thredded tzinfo-data uglifier (>= 1.3.0) + web-console webmock RUBY VERSION diff --git a/README.rdoc b/README.rdoc index 52b06c95..20b31fce 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,4 +1,4 @@ -= Notebook.ai += Notebook.ai {Build Status}[https://travis-ci.org/indentlabs/notebook] {}[https://codeclimate.com/github/indentlabs/notebook] {}[https://codeclimate.com/github/indentlabs/notebook/coverage] diff --git a/app/assets/stylesheets/navbar.css b/app/assets/stylesheets/navbar.css index 79b44f5a..28ac5698 100644 --- a/app/assets/stylesheets/navbar.css +++ b/app/assets/stylesheets/navbar.css @@ -14,4 +14,4 @@ .collection-header { padding: 0 !important; -} \ No newline at end of file +} diff --git a/app/controllers/religions_controller.rb b/app/controllers/religions_controller.rb index 548f04f4..32c7fd5a 100644 --- a/app/controllers/religions_controller.rb +++ b/app/controllers/religions_controller.rb @@ -11,10 +11,11 @@ class ReligionsController < ContentController ) + [ custom_attribute_values: [:name, :value], religious_figureships_attributes: [:id, :notable_figure_id, :_destroy], - deityships_attributes: [:id, :deity_id, :_destroy], + deityships_attributes: [:id, :deity_character_id, :_destroy], religious_locationships_attributes: [:id, :practicing_location_id, :_destroy], artifactships_attributes: [:id, :artifact_id, :_destroy], - religious_raceships_attributes: [:id, :race_id, :_destroy] + religious_raceships_attributes: [:id, :race_id, :_destroy], + religion_deities_attributes: [:id, :deity_id, :_destroy] ] end end diff --git a/app/models/concerns/has_content_groupers.rb b/app/models/concerns/has_content_groupers.rb index 94222a43..c667ce6b 100644 --- a/app/models/concerns/has_content_groupers.rb +++ b/app/models/concerns/has_content_groupers.rb @@ -12,12 +12,22 @@ module HasContentGroupers connecting_class = with.to_s.singularize.camelize.constantize connecting_class_name = with + if relation == :deity_characters + # sadface, SADFACE + singularized_relation = :deity + end + # Fetch the connecting class's through class (e.g. Character for sibling_id). # If there isn't one defined, it means it already maps to a model (e.g. race_id), # so we can use the name as the class as well. belongs_to_relations = connecting_class.reflect_on_all_associations(:belongs_to) through_relation = belongs_to_relations.detect do |relation| # sibling - relation.name.to_s == singularized_relation + # sadface + if relation.name == :deity_character && singularized_relation == :deity + true + else + relation.name.to_s == singularized_relation + end end if through_relation.options.key?(:class_name) through_relation_class = through_relation.options[:class_name] # Character diff --git a/app/models/content_groupers/deityship.rb b/app/models/content_groupers/deityship.rb index 10a0a5df..350cd515 100644 --- a/app/models/content_groupers/deityship.rb +++ b/app/models/content_groupers/deityship.rb @@ -2,7 +2,18 @@ class Deityship < ApplicationRecord include HasContentLinking belongs_to :user - belongs_to :religion - belongs_to :deity, class_name: 'Character' + + # This is hacky because we had Deityships pointing at character "deities" before + # actually having deity models. When we added a ReligionDeityship that points to + # a deity "deity", this got renamed to "deity_character" and we needed this + # foreign key / alias. + belongs_to :deity_character, class_name: 'Character', foreign_key: 'deity_id' + def deity_character_id + deity_id + end + + def deity_character_id=(x) + self.deity_id = x + end end diff --git a/app/models/content_groupers/religion_deity.rb b/app/models/content_groupers/religion_deity.rb new file mode 100644 index 00000000..316322ba --- /dev/null +++ b/app/models/content_groupers/religion_deity.rb @@ -0,0 +1,6 @@ +class ReligionDeity < ActiveRecord::Base + belongs_to :user + + belongs_to :religion + belongs_to :deity +end diff --git a/app/models/content_types/religion.rb b/app/models/content_types/religion.rb index 47d7b12b..0489e48f 100644 --- a/app/models/content_types/religion.rb +++ b/app/models/content_types/religion.rb @@ -21,7 +21,7 @@ class Religion < ApplicationRecord # Characters relates :notable_figures, with: :religious_figureships - relates :deities, with: :deityships + relates :deity_characters, with: :deityships # Locations relates :practicing_locations, with: :religious_locationships @@ -32,6 +32,9 @@ class Religion < ApplicationRecord # Races relates :races, with: :religious_raceships + # Deities + relates :deities, with: :religion_deities + def self.color 'yellow' end diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb index ae13d3b9..92d5bcb6 100644 --- a/app/views/layouts/_navbar.html.erb +++ b/app/views/layouts/_navbar.html.erb @@ -123,11 +123,16 @@