form_creation 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9de7eefbc68a41151161baf02607f1589384ab28029718c608fed96abef943db
4
- data.tar.gz: d2ccf29885bd0526181ffc20c6971229cfedef244025f526ede8b7470f3747ce
3
+ metadata.gz: 4eedf3c04235a05871edfbcbdd522538868f2886560ce7259e2d4973c8be231a
4
+ data.tar.gz: 75a913d71eb2067c9061f50acbb2fa2a13d7f16281b8723fa1f3150ca7bbe173
5
5
  SHA512:
6
- metadata.gz: 8c026c4a74d1f617b3da69db87c2753440e660cb0501944a575e47433822afaad3f2be8841fee85df567502ff96983754494116e830c77b76fe11f61da145acc
7
- data.tar.gz: 7c225032e23daccb77309b0796874077b7a5f02edc4e209ed8b93d494f7bed0faf05181a62112bfeb4ba1e6aba24672b865749535a79460dec00b39f131c763c
6
+ metadata.gz: d308584985c7971cc1a9ed7418671ece753644eaa0edce23546cbc988f499f7a2a404cba9b857fe8824152344ed17bfb15fcea8adf2354e270514a1a582c2fcb
7
+ data.tar.gz: 424ced95e950bd9235bce626f3eab6c6c6a0a8c1d2ff0d19aa04f2805146db7e43bbc48ce7ed63a1e3e2568c9424366b00950b2c4cb04ed977357245ba7d1495
data/README.md CHANGED
@@ -20,6 +20,17 @@ Or install it yourself as:
20
20
  ```bash
21
21
  $ gem install form_creation
22
22
  ```
23
+ ## Migration
24
+ $ rails form_creation:install:migrations
25
+
26
+ $ rails db:migrate
27
+
28
+ ## Routes
29
+ mount FormCreation::Engine => "/form_creation"
30
+
31
+ root :to => "posts#new"
32
+ ## Visit
33
+ http://localhost:3000/form_creation
23
34
 
24
35
  ## Contributing
25
36
  Contribution directions go here.
@@ -2,3 +2,10 @@
2
2
  Place all the styles related to the matching controller here.
3
3
  They will automatically be included in application.css.
4
4
  */
5
+ .post {
6
+ width: 400px !important;
7
+ margin: 70px auto !important;
8
+ border: 1px solid #ccc;
9
+ padding: 32px;
10
+ border-radius: 3px;
11
+ }
@@ -3,7 +3,7 @@ require_dependency "form_creation/application_controller"
3
3
  module FormCreation
4
4
  class PostsController < ApplicationController
5
5
  def index
6
- @posts = Post.all
6
+ @posts = Post.order('id DESC')
7
7
  end
8
8
 
9
9
  # GET method to get a Post by id
@@ -1,30 +1,28 @@
1
- <div class="container">
1
+ <div class="container post">
2
2
  <%= form_for @post, url: {action: :update} do |f| %>
3
3
  <div>
4
- <h3>Update a Post</h3>
4
+ <h3>Update Post</h3>
5
5
  </div>
6
6
  <div>
7
7
  <p>
8
8
  <%= "<div>#{@post.errors.full_messages.first}</div>".html_safe if @post.errors.any? %>
9
- <div>
9
+ <div class="form-group">
10
10
  <label>Title</label>
11
- <%= f.text_field :title %>
11
+ <%= f.text_field :title, class: "form-control" %>
12
12
  </div>
13
-
14
- <div>
13
+ <div class="form-group">
15
14
  <label>Description</label>
16
- <%= f.text_field :description %>
15
+ <%= f.text_area :description, class: "form-control", rows: "5", cols: "10", style: "resize:none;" %>
17
16
  </div>
18
-
19
- <div>
20
- <label>Created_by</label>
21
- <%= f.text_field :created_by %>
17
+ <div class="form-group">
18
+ <label>Created_by</label>
19
+ <%= f.text_field :created_by, class: "form-control" %>
22
20
  </div>
23
21
  </p>
24
22
  </div>
25
- <div>
26
- <%= link_to 'Back', posts_path %>
27
- <%= f.submit 'Update Post' %>
23
+ <div class="row">
24
+ <div class="col-md-8"><%= link_to 'Back', posts_path, class: "btn btn-info" %></div>
25
+ <div class="col-md-4"><%= f.submit 'Update Post', class: "btn btn-success" %></div>
28
26
  </div>
29
27
  <% end %>
30
28
  </div>
@@ -1,5 +1,8 @@
1
1
  <div class="container" style="margin-top: 70px;">
2
- <h3>Posts</h3>
2
+ <h3>Posts</h3>
3
+ <div style="margin-bottom: 10px;">
4
+ <%= link_to 'Add User', new_post_path, class: "btn btn-success" %>
5
+ </div>
3
6
  <table class="table table-striped">
4
7
  <thead>
5
8
  <tr>
@@ -16,15 +19,12 @@
16
19
  <td><%= p.description %></td>
17
20
  <td><%= p.created_by %></td>
18
21
  <td>
19
- <%= link_to 'Show', post_path(p) %>
20
- <%= link_to 'Edit', edit_post_path(p) %>
21
- <%= link_to 'Delete', post_path(p), method: :delete %>
22
+ <%= link_to 'Show', post_path(p), class: "btn btn-info" %>
23
+ <%= link_to 'Edit', edit_post_path(p), class: "btn btn-warning"%>
24
+ <%= link_to 'Delete', post_path(p), method: :delete, class: "btn btn-danger" %>
22
25
  </td>
23
26
  </tr>
24
27
  <% end %>
25
28
  </tbody>
26
29
  </table>
27
30
  </div>
28
- <div>
29
- <%= link_to 'Add User', new_post_path %>
30
- </div>
@@ -1,4 +1,4 @@
1
- <div class="container">
1
+ <div class="container post">
2
2
  <%= form_for @post, url: {action: :create} do |f| %>
3
3
  <div>
4
4
  <h3>Add a Post</h3>
@@ -6,25 +6,23 @@
6
6
  <div>
7
7
  <p>
8
8
  <%= "<div>#{@post.errors.full_messages.first}</div>".html_safe if @post.errors.any? %>
9
- <div>
9
+ <div class="form-group">
10
10
  <label>Title</label>
11
- <%= f.text_field :title %>
11
+ <%= f.text_field :title, class: "form-control" %>
12
12
  </div>
13
-
14
- <div>
13
+ <div class="form-group">
15
14
  <label>Description</label>
16
- <%= f.text_field :description %>
15
+ <%= f.text_area :description, class: "form-control", rows: "5", cols: "10", style: "resize:none;" %>
17
16
  </div>
18
-
19
- <div>
20
- <label>Created_by</label>
21
- <%= f.text_field :created_by %>
17
+ <div class="form-group">
18
+ <label>Created_by</label>
19
+ <%= f.text_field :created_by, class: "form-control" %>
22
20
  </div>
23
21
  </p>
24
22
  </div>
25
- <div>
26
- <%= link_to 'Back', posts_path %>
27
- <%= f.submit 'Create Post' %>
23
+ <div class="row">
24
+ <div class="col-md-8"><%= link_to 'Back', posts_path, class: "btn btn-info" %></div>
25
+ <div class="col-md-4"><%= f.submit 'Create Post', class: "btn btn-success" %></div>
28
26
  </div>
29
27
  <% end %>
30
28
  </div>
@@ -1,2 +1,18 @@
1
- <h1>Posts#show</h1>
2
- <p>Find me in app/views/form_creation/posts/show.html.erb</p>
1
+ <div class="container post">
2
+ <h3>Post Details</h3>
3
+ <div>
4
+ <label><b>Title:</b></label>
5
+ <%= @post.title %>
6
+ </div>
7
+ <div>
8
+ <label><b>Description:</b></label>
9
+ <%= @post.description %>
10
+ </div>
11
+ <div>
12
+ <label><b>Created_by:</b></label>
13
+ <%= @post.created_by %>
14
+ </div>
15
+ <div>
16
+ <%= link_to 'Back', posts_path, class: "btn btn-info" %>
17
+ </div>
18
+ </div>
@@ -7,6 +7,7 @@
7
7
 
8
8
  <%= stylesheet_link_tag "form_creation/application", media: "all" %>
9
9
  <%= javascript_include_tag "form_creation/application" %>
10
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
10
11
  </head>
11
12
  <body>
12
13
 
data/config/routes.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  FormCreation::Engine.routes.draw do
2
2
  resources :posts
3
- root "form_creation/posts#index"
3
+ root :to => "posts#index"
4
4
  end
@@ -1,9 +1,9 @@
1
1
  class CreateFormCreationPosts < ActiveRecord::Migration[5.2]
2
2
  def change
3
- create_table :posts do |t|
3
+ create_table :form_creation_posts do |t|
4
4
  t.string :title
5
5
  t.text :description
6
- t.string :createdby
6
+ t.string :created_by
7
7
 
8
8
  t.timestamps
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module FormCreation
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: form_creation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - madhubabu-nyros