phcdevworks_tutorials 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/phcdevworks_tutorials/tutorial/categories_controller.rb +2 -0
- data/app/controllers/phcdevworks_tutorials/tutorial/posts_controller.rb +2 -0
- data/app/models/phcdevworks_tutorials/tutorial/category.rb +19 -0
- data/app/models/phcdevworks_tutorials/tutorial/post.rb +21 -1
- data/config/initializers/friendly_id.rb +107 -0
- data/config/routes.rb +1 -1
- data/lib/phcdevworks_tutorials/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcd0ce05dfbe3900903ae92a916eadc062eb8f671a4b45ae6a0f991925f7e4d4
|
4
|
+
data.tar.gz: 79184d9aad19bc6bdce434638563f36116a5da63672f78083bc09a829c68e92d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 620326c3839bc41b6e0e3dc62e41785eae68a842abdc858a15841e6df50cf4a4bed556fc17e8df4e7cc5b7127898bc3966a4ea9beb0b6dfbea9246960abf608e
|
7
|
+
data.tar.gz: 5f9fa81875b042e31b8b6f8ca8e2e6433a045a5b34c371d7a49d05ea49ed7dcd2700bd04782f71145be6a56893d386be79e050e2794a83defbefe60bf78f2f75
|
@@ -30,6 +30,8 @@ module PhcdevworksTutorials
|
|
30
30
|
# POST /tutorial/categories
|
31
31
|
def create
|
32
32
|
@tutorial_category = Tutorial::Category.new(tutorial_category_params)
|
33
|
+
@tutorial_category.user_id = current_user.id
|
34
|
+
@tutorial_category.org_id = current_user.org_id
|
33
35
|
respond_to do |format|
|
34
36
|
if @tutorial_category.save
|
35
37
|
format.html { redirect_to tutorial_categories_path, :flash => { :success => 'Tutorial has been Added.' }}
|
@@ -30,6 +30,8 @@ module PhcdevworksTutorials
|
|
30
30
|
# POST /tutorial/posts
|
31
31
|
def create
|
32
32
|
@tutorial_post = Tutorial::Post.new(tutorial_post_params)
|
33
|
+
@tutorial_post.user_id = current_user.id
|
34
|
+
@tutorial_post.org_id = current_user.org_id
|
33
35
|
respond_to do |format|
|
34
36
|
if @tutorial_post.save
|
35
37
|
format.html { redirect_to tutorial_posts_path, :flash => { :success => 'Tutorial has been Added.' }}
|
@@ -1,4 +1,23 @@
|
|
1
1
|
module PhcdevworksTutorials
|
2
2
|
class Tutorial::Category < ApplicationRecord
|
3
|
+
|
4
|
+
# Clean URL Initialize
|
5
|
+
extend FriendlyId
|
6
|
+
|
7
|
+
#Relationships
|
8
|
+
has_many :posts, class_name: 'PhcdevworksTutorials::Tutorial::Post'
|
9
|
+
|
10
|
+
# Form Fields Validation
|
11
|
+
validates :tutorial_category_name,
|
12
|
+
presence: true,
|
13
|
+
uniqueness: true
|
14
|
+
|
15
|
+
# Clean URL Define
|
16
|
+
friendly_id :phcdev_tutorials_category_nice_urls, use: [:slugged, :finders]
|
17
|
+
|
18
|
+
def phcdev_tutorials_category_nice_urls
|
19
|
+
[:tutorial_category_name]
|
20
|
+
end
|
21
|
+
|
3
22
|
end
|
4
23
|
end
|
@@ -1,5 +1,25 @@
|
|
1
1
|
module PhcdevworksTutorials
|
2
2
|
class Tutorial::Post < ApplicationRecord
|
3
|
-
|
3
|
+
|
4
|
+
# Clean URL Initialize
|
5
|
+
extend FriendlyId
|
6
|
+
|
7
|
+
# Relationships
|
8
|
+
belongs_to :category, class_name: 'PhcdevworksTutorials::Tutorial::Category'
|
9
|
+
|
10
|
+
# Form Fields Validation
|
11
|
+
validates :tutorial_post_title,
|
12
|
+
presence: true
|
13
|
+
|
14
|
+
validates :tutorial_post_text,
|
15
|
+
presence: true
|
16
|
+
|
17
|
+
# Clean URL Define
|
18
|
+
friendly_id :phcdev_tutorials_post_nice_urls, use: [:slugged, :finders]
|
19
|
+
|
20
|
+
def phcdev_tutorials_post_nice_urls
|
21
|
+
[:tutorial_post_title]
|
22
|
+
end
|
23
|
+
|
4
24
|
end
|
5
25
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# FriendlyId Global Configuration
|
2
|
+
#
|
3
|
+
# Use this to set up shared configuration options for your entire application.
|
4
|
+
# Any of the configuration options shown here can also be applied to single
|
5
|
+
# models by passing arguments to the `friendly_id` class method or defining
|
6
|
+
# methods in your model.
|
7
|
+
#
|
8
|
+
# To learn more, check out the guide:
|
9
|
+
#
|
10
|
+
# http://norman.github.io/friendly_id/file.Guide.html
|
11
|
+
|
12
|
+
FriendlyId.defaults do |config|
|
13
|
+
# ## Reserved Words
|
14
|
+
#
|
15
|
+
# Some words could conflict with Rails's routes when used as slugs, or are
|
16
|
+
# undesirable to allow as slugs. Edit this list as needed for your app.
|
17
|
+
config.use :reserved
|
18
|
+
|
19
|
+
config.reserved_words = %w(new edit index session login logout users admin
|
20
|
+
stylesheets assets javascripts images)
|
21
|
+
|
22
|
+
# This adds an option to treat reserved words as conflicts rather than exceptions.
|
23
|
+
# When there is no good candidate, a UUID will be appended, matching the existing
|
24
|
+
# conflict behavior.
|
25
|
+
|
26
|
+
# config.treat_reserved_as_conflict = true
|
27
|
+
|
28
|
+
# ## Friendly Finders
|
29
|
+
#
|
30
|
+
# Uncomment this to use friendly finders in all models. By default, if
|
31
|
+
# you wish to find a record by its friendly id, you must do:
|
32
|
+
#
|
33
|
+
# MyModel.friendly.find('foo')
|
34
|
+
#
|
35
|
+
# If you uncomment this, you can do:
|
36
|
+
#
|
37
|
+
# MyModel.find('foo')
|
38
|
+
#
|
39
|
+
# This is significantly more convenient but may not be appropriate for
|
40
|
+
# all applications, so you must explicity opt-in to this behavior. You can
|
41
|
+
# always also configure it on a per-model basis if you prefer.
|
42
|
+
#
|
43
|
+
# Something else to consider is that using the :finders addon boosts
|
44
|
+
# performance because it will avoid Rails-internal code that makes runtime
|
45
|
+
# calls to `Module.extend`.
|
46
|
+
#
|
47
|
+
# config.use :finders
|
48
|
+
#
|
49
|
+
# ## Slugs
|
50
|
+
#
|
51
|
+
# Most applications will use the :slugged module everywhere. If you wish
|
52
|
+
# to do so, uncomment the following line.
|
53
|
+
#
|
54
|
+
# config.use :slugged
|
55
|
+
#
|
56
|
+
# By default, FriendlyId's :slugged addon expects the slug column to be named
|
57
|
+
# 'slug', but you can change it if you wish.
|
58
|
+
#
|
59
|
+
# config.slug_column = 'slug'
|
60
|
+
#
|
61
|
+
# By default, slug has no size limit, but you can change it if you wish.
|
62
|
+
#
|
63
|
+
# config.slug_limit = 255
|
64
|
+
#
|
65
|
+
# When FriendlyId can not generate a unique ID from your base method, it appends
|
66
|
+
# a UUID, separated by a single dash. You can configure the character used as the
|
67
|
+
# separator. If you're upgrading from FriendlyId 4, you may wish to replace this
|
68
|
+
# with two dashes.
|
69
|
+
#
|
70
|
+
# config.sequence_separator = '-'
|
71
|
+
#
|
72
|
+
# Note that you must use the :slugged addon **prior** to the line which
|
73
|
+
# configures the sequence separator, or else FriendlyId will raise an undefined
|
74
|
+
# method error.
|
75
|
+
#
|
76
|
+
# ## Tips and Tricks
|
77
|
+
#
|
78
|
+
# ### Controlling when slugs are generated
|
79
|
+
#
|
80
|
+
# As of FriendlyId 5.0, new slugs are generated only when the slug field is
|
81
|
+
# nil, but if you're using a column as your base method can change this
|
82
|
+
# behavior by overriding the `should_generate_new_friendly_id?` method that
|
83
|
+
# FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave
|
84
|
+
# more like 4.0.
|
85
|
+
# Note: Use(include) Slugged module in the config if using the anonymous module.
|
86
|
+
# If you have `friendly_id :name, use: slugged` in the model, Slugged module
|
87
|
+
# is included after the anonymous module defined in the initializer, so it
|
88
|
+
# overrides the `should_generate_new_friendly_id?` method from the anonymous module.
|
89
|
+
#
|
90
|
+
# config.use :slugged
|
91
|
+
# config.use Module.new {
|
92
|
+
# def should_generate_new_friendly_id?
|
93
|
+
# slug.blank? || <your_column_name_here>_changed?
|
94
|
+
# end
|
95
|
+
# }
|
96
|
+
#
|
97
|
+
# FriendlyId uses Rails's `parameterize` method to generate slugs, but for
|
98
|
+
# languages that don't use the Roman alphabet, that's not usually sufficient.
|
99
|
+
# Here we use the Babosa library to transliterate Russian Cyrillic slugs to
|
100
|
+
# ASCII. If you use this, don't forget to add "babosa" to your Gemfile.
|
101
|
+
#
|
102
|
+
# config.use Module.new {
|
103
|
+
# def normalize_friendly_id(text)
|
104
|
+
# text.to_slug.normalize! :transliterations => [:russian, :latin]
|
105
|
+
# end
|
106
|
+
# }
|
107
|
+
end
|
data/config/routes.rb
CHANGED
@@ -3,7 +3,7 @@ PhcdevworksTutorials::Engine.routes.draw do
|
|
3
3
|
# Tutorial Routs
|
4
4
|
namespace :tutorial do
|
5
5
|
resources :posts, class_name: 'PhcdevworksTutorials::Tutorial::Post'
|
6
|
-
resources :categories, class_name: 'PhcdevworksTutorials::Tutorial::Category'
|
6
|
+
resources :categories, class_name: 'PhcdevworksTutorials::Tutorial::Category'
|
7
7
|
end
|
8
8
|
|
9
9
|
# Frontend Routes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phcdevworks_tutorials
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PHCDevworks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -198,14 +198,14 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: 1.0
|
201
|
+
version: 1.1.0
|
202
202
|
type: :runtime
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: 1.0
|
208
|
+
version: 1.1.0
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: sqlite3
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -275,6 +275,7 @@ files:
|
|
275
275
|
- app/views/phcdevworks_tutorials/tutorial/posts/index.html.erb
|
276
276
|
- app/views/phcdevworks_tutorials/tutorial/posts/new.html.erb
|
277
277
|
- app/views/phcdevworks_tutorials/tutorial/posts/show.html.erb
|
278
|
+
- config/initializers/friendly_id.rb
|
278
279
|
- config/routes.rb
|
279
280
|
- db/migrate/20190911225813_create_phcdevworks_tutorials_tutorial_posts.rb
|
280
281
|
- db/migrate/20190911225925_create_phcdevworks_tutorials_tutorial_categories.rb
|