Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update mobility-ransack to 1.2.2 (ransack 4.1.1) #60

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ gem "administrate", "~> 0.18.0"

# Translatable content
gem "mobility", "~> 1.2"
gem "mobility-ransack", "~> 1.2"
gem "mobility-ransack", "~> 1.2.2"

# Soft deletions
gem "discard", "~> 1.2"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ DEPENDENCIES
jsbundling-rails (~> 1.0)
kaminari (~> 1.2)
mobility (~> 1.2)
mobility-ransack (~> 1.2)
mobility-ransack (~> 1.2.2)
pg (~> 1.1)
puma (~> 6.4)
pundit (~> 2.2)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/stories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class StoriesController < ApplicationController

def index
# Fields to search for
@search_fields = :title_or_description_or_outcomes_or_source_or_story_updates_title_i_cont_any
@search_fields = :title_or_description_or_outcomes_or_source_or_story_updates_title_or_story_updates_description_i_cont_any

# Inspired from https://github.com/activerecord-hackery/ransack/issues/218#issuecomment-16504630
# Make sure multiple words are split and searched
Expand Down
8 changes: 8 additions & 0 deletions app/models/story.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ class Story < ApplicationRecord
discussions.undiscard_all
end

def self.ransackable_attributes(auth_object = nil)
%w[title description outcomes source country]
end

def self.ransackable_associations(auth_object = nil)
%w[story_updates]
end

# https://github.com/countries/country_select#getting-the-country-name-from-the-countries-gem
# Assuming country_select is used with User attribute `country`
# This will attempt to translate the country name and use the default
Expand Down
8 changes: 8 additions & 0 deletions app/models/story_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ class StoryUpdate < ApplicationRecord

validates :title, :description, presence: true
translates :title, :description

def self.ransackable_attributes(auth_object = nil)
%w[title description]
end

def self.ransackable_associations(auth_object = nil)
%w[story]
end
end