phcdevworks_tutorials 1.2.1 → 1.2.2

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: b93b2be698a2b6af5d1caef7359a18c9982a913d9418baae3a1b1ab265fc2f78
4
- data.tar.gz: c35a37c51964b9d31d6ed9df137e1e72cec8ef2f8daab6cc248422f97c094515
3
+ metadata.gz: 4f20962d4a1dcee4e01f921bb7fe0e413d3f57f9de8c71d1b0413cb7f516e7fd
4
+ data.tar.gz: '09615f03b8c76ce654fc100cc73c6eca19d2a884a84458da7718560ebf2e5793'
5
5
  SHA512:
6
- metadata.gz: 23f22943873bb93365bfda9b15e29b25d86ed8bc315e160b8b776cdb747445c063ca5218cb37742ea59b0b28bea2fe7defb8fb3523abc3741c9a82138dd4d4f6
7
- data.tar.gz: f79b366422c3e9c0dd60b2c24136fde739c0eb49bae9fb25cdf8c666c0274abf6da53e87be979dc835e418d867af3143c2e60fa86fa2b88b22e42e8e101ac937
6
+ metadata.gz: 07dcd4698effa6821abfd3315bdac1661827a2cb1e48eac822ab64ff08118056cc77461471c5ef7c82617728566d53d6bd5961e97ea6c2131dd4589bf22cc4c1
7
+ data.tar.gz: 6ce3ecd655f8a390c99ac6c313f8e7802b7ee846382ce963a071ec52cee2fb6d15fcdfc81b642f83c1b1d53194cbc400d5a22a776b0c3582665f279d851ff8b1
@@ -75,7 +75,7 @@ module PhcdevworksTutorials
75
75
 
76
76
  # Whitelist
77
77
  def tutorial_post_params
78
- params.require(:tutorial_post).permit(:tutorial_post_step, :tutorial_post_title, :tutorial_post_text,:tutorial_post_description, :tutorial_post_status, :tutorial_post_image, :category_id, :slug, :user_id, :org_id)
78
+ params.require(:tutorial_post).permit(:tutorial_post_step, :tutorial_post_title, :tutorial_post_text,:tutorial_post_description, :tutorial_post_status, :tutorial_post_image, :slug, :user_id, :org_id, category_ids: [])
79
79
  end
80
80
 
81
81
  end
@@ -5,7 +5,7 @@ module PhcdevworksTutorials
5
5
  extend FriendlyId
6
6
 
7
7
  #Relationships
8
- has_many :posts, class_name: 'PhcdevworksTutorials::Tutorial::Post'
8
+ has_and_belongs_to_many :posts, class_name: 'Tutorial::Post', :join_table => 'categories_posts', :dependent => :destroy
9
9
 
10
10
  # Form Fields Validation
11
11
  validates :tutorial_category_name,
@@ -8,8 +8,8 @@ module PhcdevworksTutorials
8
8
  has_one_attached :tutorial_post_image
9
9
 
10
10
  # Relationships
11
- belongs_to :category, class_name: 'PhcdevworksTutorials::Tutorial::Category'
12
- has_many :steps, class_name: "PhcdevworksTutorials::Tutorial::Step"
11
+ has_and_belongs_to_many :categories, class_name: 'Tutorial::Category', :join_table => 'categories_posts', :dependent => :destroy
12
+ has_many :steps, class_name: "Tutorial::Step"
13
13
 
14
14
  # Form Fields Validation
15
15
  validates :tutorial_post_title,
@@ -32,7 +32,12 @@
32
32
 
33
33
  <div class="form-group field_with_errors">
34
34
  <label>Select a Category</label>
35
- <%= form.collection_select :category_id, PhcdevworksTutorials::Tutorial::Category.order(:tutorial_category_name),:id, :tutorial_category_name, {}, {class: "form-control"} %>
35
+ <div class="panel-body">
36
+ <%= form.collection_check_boxes :category_ids, PhcdevworksTutorials::Tutorial::Category.order(:tutorial_category_name), :id, :tutorial_category_name do |post_category| %>
37
+ <%= post_category.check_box %>
38
+ <%= post_category.label %><br>
39
+ <% end %>
40
+ </div>
36
41
  </div>
37
42
  <!-- Form Input Fields -->
38
43
 
@@ -37,7 +37,8 @@
37
37
  <thead>
38
38
  <tr>
39
39
  <th>Tutorial Title</th>
40
- <th>Tutorial Category</th>
40
+ <th>Tutorial Description</th>
41
+ <th>Tutorial Status</th>
41
42
  <th></th>
42
43
  </tr>
43
44
  </thead>
@@ -46,7 +47,8 @@
46
47
  <% @tutorial_posts.each do |tutorial_post| %>
47
48
  <tr>
48
49
  <td><%= tutorial_post.tutorial_post_title %></td>
49
- <td><%= tutorial_post.category.tutorial_category_name %></td>
50
+ <td><%= tutorial_post.tutorial_post_description %></td>
51
+ <td><%= tutorial_post.tutorial_post_status %></td>
50
52
  <td>
51
53
  <div class="btn-group d-flex" role="group">
52
54
  <%= link_to "Details", tutorial_post, class: "btn btn-purple btn-xs" %>
@@ -4,8 +4,6 @@ class CreatePhcdevworksTutorialsTutorialPosts < ActiveRecord::Migration[6.0]
4
4
 
5
5
  t.string :tutorial_post_title
6
6
 
7
- t.references :category
8
-
9
7
  t.string :slug
10
8
  t.string :user_id
11
9
  t.string :org_id
@@ -0,0 +1,10 @@
1
+ class CreateJoinTableCategoriesPosts < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_join_table :categories, :posts do |t|
4
+
5
+ # t.index [:category_id, :post_id]
6
+ # t.index [:post_id, :category_id]
7
+
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module PhcdevworksTutorials
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
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: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - PHCDevworks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-02 00:00:00.000000000 Z
11
+ date: 2019-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -289,6 +289,7 @@ files:
289
289
  - db/migrate/20190929044403_add_info_to_phcdevworks_tutorials_tutorial_posts.rb
290
290
  - db/migrate/20190929044505_add_info_to_phcdevworks_tutorials_tutorial_steps.rb
291
291
  - db/migrate/20191002093451_add_image_to_phcdevworks_tutorials_tutorial_posts.rb
292
+ - db/migrate/20191003235303_create_join_table_categories_posts.rb
292
293
  - lib/phcdevworks_tutorials.rb
293
294
  - lib/phcdevworks_tutorials/engine.rb
294
295
  - lib/phcdevworks_tutorials/version.rb