forked from zauberware/rails-devise-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
760de84
commit e0996bb
Showing
16 changed files
with
209 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
# GraphQL type for a user | ||
# GraphQL type for an account | ||
class AccountType < BaseModel | ||
field :name, String, null: false | ||
field :slug, String, null: true | ||
# field :users, [::Types::UserType], null: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# frozen_string_literal: true | ||
|
||
# FriendlyId Global Configuration | ||
# | ||
# Use this to set up shared configuration options for your entire application. | ||
# Any of the configuration options shown here can also be applied to single | ||
# models by passing arguments to the `friendly_id` class method or defining | ||
# methods in your model. | ||
# | ||
# To learn more, check out the guide: | ||
# | ||
# http://norman.github.io/friendly_id/file.Guide.html | ||
FriendlyId.defaults do |config| | ||
# ## Reserved Words | ||
# | ||
# Some words could conflict with Rails's routes when used as slugs, or are | ||
# undesirable to allow as slugs. Edit this list as needed for your app. | ||
config.use :reserved | ||
|
||
config.reserved_words = %w[new edit index session login logout users admin | ||
stylesheets assets javascripts images] | ||
|
||
# ## Friendly Finders | ||
# | ||
# Uncomment this to use friendly finders in all models. By default, if | ||
# you wish to find a record by its friendly id, you must do: | ||
# | ||
# MyModel.friendly.find('foo') | ||
# | ||
# If you uncomment this, you can do: | ||
# | ||
# MyModel.find('foo') | ||
# | ||
# This is significantly more convenient but may not be appropriate for | ||
# all applications, so you must explicity opt-in to this behavior. You can | ||
# always also configure it on a per-model basis if you prefer. | ||
# | ||
# Something else to consider is that using the :finders addon boosts | ||
# performance because it will avoid Rails-internal code that makes runtime | ||
# calls to `Module.extend`. | ||
# | ||
# config.use :finders | ||
# | ||
# ## Slugs | ||
# | ||
# Most applications will use the :slugged module everywhere. If you wish | ||
# to do so, uncomment the following line. | ||
# | ||
# config.use :slugged | ||
# | ||
# By default, FriendlyId's :slugged addon expects the slug column to be named | ||
# 'slug', but you can change it if you wish. | ||
# | ||
# config.slug_column = 'slug' | ||
# | ||
# When FriendlyId can not generate a unique ID from your base method, it appends | ||
# a UUID, separated by a single dash. You can configure the character used as the | ||
# separator. If you're upgrading from FriendlyId 4, you may wish to replace this | ||
# with two dashes. | ||
# | ||
# config.sequence_separator = '-' | ||
# | ||
# ## Tips and Tricks | ||
# | ||
# ### Controlling when slugs are generated | ||
# | ||
# As of FriendlyId 5.0, new slugs are generated only when the slug field is | ||
# nil, but if you're using a column as your base method can change this | ||
# behavior by overriding the `should_generate_new_friendly_id` method that | ||
# FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave | ||
# more like 4.0. | ||
# | ||
# config.use Module.new { | ||
# def should_generate_new_friendly_id? | ||
# slug.blank? || <your_column_name_here>_changed? | ||
# end | ||
# } | ||
# | ||
# FriendlyId uses Rails's `parameterize` method to generate slugs, but for | ||
# languages that don't use the Roman alphabet, that's not usually sufficient. | ||
# Here we use the Babosa library to transliterate Russian Cyrillic slugs to | ||
# ASCII. If you use this, don't forget to add "babosa" to your Gemfile. | ||
# | ||
# config.use Module.new { | ||
# def normalize_friendly_id(text) | ||
# text.to_slug.normalize! :transliterations => [:russian, :latin] | ||
# end | ||
# } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
de: | ||
attributes: | ||
slug: Pfad | ||
activerecord: | ||
attributes: | ||
account: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddSlugToAccounts < ActiveRecord::Migration[6.0] | ||
def change | ||
add_column :accounts, :slug, :string | ||
add_index :accounts, :slug, unique: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class CreateFriendlyIdSlugs < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table :friendly_id_slugs do |t| | ||
t.string :slug, :null => false | ||
t.integer :sluggable_id, :null => false | ||
t.string :sluggable_type, :limit => 50 | ||
t.string :scope | ||
t.datetime :created_at | ||
end | ||
add_index :friendly_id_slugs, :sluggable_id | ||
add_index :friendly_id_slugs, [:slug, :sluggable_type] | ||
add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], :unique => true | ||
add_index :friendly_id_slugs, :sluggable_type | ||
|
||
Account.all.each(&:save) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.