site_blog 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59fe18f766baca355592c03228df6214a9ca9370b46d8419c5819120abd487b9
4
- data.tar.gz: 3e06efe39ced409bdc71042e7a641a2b9d666b272c0e05045a287857dc845ab8
3
+ metadata.gz: cab7ac4ecc8185d4c4767188b5ea55b94a80670e2e8b3b7a82eede29cf7e35c0
4
+ data.tar.gz: 6978b193b7ec06015ce25b6eb1e830004bf5cc8afba4b3c89e4095e2f6d366c1
5
5
  SHA512:
6
- metadata.gz: 0bdeb913978e58662f36c7928a442a5ab24ef79fb28b262b3f04b0d363255fbc133383397f3efa1754055ee5c65430f56fffa2584a8f09d43903ddf1e704e15b
7
- data.tar.gz: 3a9de2774549820a8defc10c49ca65c338d97c6d1f95803bfbb9833559ca251a431fdf32f3d44d757f5b27d8d4b216cc3e32e1142181ee15b367c909a08eed25
6
+ metadata.gz: a3aa2e2048e05a1ec032d540931686a824a971274c42353be6c2eaf67bc3bbae7394c069bcc3ae8b508d1031c1ea8c1fccf2c6c55694dfcbb0d5a460da7bddde
7
+ data.tar.gz: 545a4d6b16c671674e1c8b4a808a4434f52fe10a84f325629b1294babb2a53cb5337c63fed6415dba94857056d03b664c5edb42d802c114e133a7750c6756934
@@ -4,7 +4,7 @@ module SiteBlog
4
4
 
5
5
  # GET /tags
6
6
  def index
7
- render json: Tag.all
7
+ render json: Tag.archived(false)
8
8
  end
9
9
 
10
10
  # GET /tags/1
@@ -47,7 +47,7 @@ module SiteBlog
47
47
 
48
48
  # Only allow a list of trusted parameters through.
49
49
  def tag_params
50
- params.require(:tag).permit(:slug, :arichived)
50
+ params.require(:tag).permit(:slug, :archived)
51
51
  end
52
52
  end
53
53
  end
@@ -45,7 +45,7 @@ module SiteBlog
45
45
  }
46
46
 
47
47
  def self.main
48
- if self.archived(false).where(main: true).exist?
48
+ if self.archived(false).where(main: true).exists?
49
49
  res = self.archived(false).where(main: true).last
50
50
  else
51
51
  res = self.order('created_at DESC').first
@@ -7,6 +7,8 @@ module SiteBlog
7
7
 
8
8
  before_validation :slug_downcase
9
9
 
10
+ scope :archived, -> (param = true) { where(archived: param) }
11
+
10
12
  private
11
13
 
12
14
  def slug_downcase
data/config/routes.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  SiteBlog::Engine.routes.draw do
2
2
  resources :tags
3
- resources :articles do
4
- get :main, on: :collection
5
- end
3
+ get 'articles/main' => 'articles#main'
4
+ resources :articles
6
5
  end
@@ -2,18 +2,18 @@ class AddArticleAndTag < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  create_table :site_blog_tags do |t|
4
4
  t.string :slug
5
- t.boolean :archived, null: false, default: false
5
+ t.boolean :archived, null: false, default: false, index: true
6
6
  t.timestamps
7
7
  end
8
8
 
9
9
  create_table :site_blog_articles do |t|
10
10
  t.string :title, null: false
11
- t.string :slug, null: false
11
+ t.string :slug, null: false, unique: true, index: true
12
12
  t.text :html_description, null: false
13
13
  t.text :description, null: false
14
14
  t.string :image, null: false
15
15
  t.integer :view_count, null: false, default: 0
16
- t.boolean :archived, null: false, default: false
16
+ t.boolean :archived, null: false, default: false, index: true
17
17
  t.boolean :active, null: false, default: true
18
18
  t.boolean :main, null: false, default: false
19
19
  t.string :locale, null: false
@@ -25,8 +25,5 @@ class AddArticleAndTag < ActiveRecord::Migration[7.0]
25
25
  t.belongs_to :tag, foreign_key: { to_table: :site_blog_tags }
26
26
  t.timestamps
27
27
  end
28
-
29
- add_index :site_blog_articles, :slug, unique: true
30
- add_index :site_blog_articles, [:slug, :archived]
31
28
  end
32
29
  end
@@ -1,3 +1,3 @@
1
1
  module SiteBlog
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site_blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eldar