form_creation 0.0.5 → 0.0.6

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: ea9373f8d676ae5e183af3b7f1899780aa33aeb942d749b04e38943a8c7c1fa6
4
- data.tar.gz: f9c29250de140dcc44993f18493b5eba3efc19435f689ed08ba52fd20db1716e
3
+ metadata.gz: d667bd350a0a808775ceca5187d2c2f8b8dc6ef9b2bdf32ff07db2d41a35c133
4
+ data.tar.gz: e5bc3844bcab82063b94bf02cefc3a90fc590358c7c4fc55aaba6a00e6875a00
5
5
  SHA512:
6
- metadata.gz: 694d1f9b52abb4925cde56db0f3973a386428fac7b39a398746a4f245d1eea3d0e42b6df1b29427fc7c49a8fa289201e0be0fb5c9521af9002a62576c3d84368
7
- data.tar.gz: 40f785340a8be07c3f9b56855d5ea358f0ed48d253d1b864153d49f371b0a9a34be76b97e7321621ca36e54a4837240a1a11736f116f3df7499a9cc2dccb0b13
6
+ metadata.gz: bd26bc558d7e25def7668a7cba1422c412b95efc1c1f0bf508dea267870732a329b59e62cb7ce08d79c9eccf035c6bccef619fb1549a68f56b2870554b5209bd
7
+ data.tar.gz: c7e41458b6b2f529643a1916a59c4a444d5f644c675587e852e06633ed476b504203425d23b21bd8c47c2a3291883afdae53cdb3f47b44038ce452ee13f3091a
@@ -10,6 +10,7 @@
10
10
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
+ //= require jquery
13
14
  //= require rails-ujs
14
15
  //= require activestorage
15
16
  //= require_tree .
@@ -1,2 +1,17 @@
1
1
  // Place all the behaviors and hooks related to the matching controller here.
2
2
  // All this logic will automatically be available in application.js.
3
+
4
+ $(document).ready(function(){
5
+ $("#new_post").validate({
6
+ rules: {
7
+ title: "required",
8
+ description: "required",
9
+ created_by: "required",
10
+ },
11
+ messages: {
12
+ title: "Please enter title",
13
+ description: "Please enter description",
14
+ created_by: "Please enter create_by",
15
+ },
16
+ });
17
+ });
@@ -8,4 +8,17 @@
8
8
  border: 1px solid #ccc;
9
9
  padding: 32px;
10
10
  border-radius: 3px;
11
+ }
12
+ .post-1 {
13
+ width: 300px !important;
14
+ margin: 70px auto !important;
15
+ border: 1px solid #ccc;
16
+ padding: 32px;
17
+ border-radius: 3px;
18
+ box-shadow: 2px 2px #ccc;
19
+ background-color: #f9f8f8;
20
+ }
21
+ .error {
22
+ color: red;
23
+ font-size: 14px;
11
24
  }
@@ -18,13 +18,13 @@ module FormCreation
18
18
 
19
19
  # POST method for processing form data
20
20
  def create
21
- @post = Post.new(post_params)
22
- if @post.save
21
+ @post = Post.new(post_params)
22
+ if @post.save
23
23
  flash[:notice] = 'Post added!'
24
24
  redirect_to posts_path
25
- else
25
+ else
26
26
  flash[:error] = 'Failed to edit Post!'
27
- render :new
27
+ render :new
28
28
  end
29
29
  end
30
30
 
@@ -59,7 +59,7 @@ module FormCreation
59
59
 
60
60
  # we used strong parameters for the validation of params
61
61
  def post_params
62
- params.require(:post).permit(:title, :description, :created_by)
62
+ params.permit(:title, :description, :created_by)
63
63
  end
64
64
  end
65
65
  end
@@ -1,4 +1,7 @@
1
1
  module FormCreation
2
2
  class Post < ApplicationRecord
3
+ # validates :title, presence: true
4
+ # validates :description, presence: true
5
+ # validates :created_by, presence: true
3
6
  end
4
- end
7
+ end
@@ -8,15 +8,15 @@
8
8
  <%= "<div>#{@post.errors.full_messages.first}</div>".html_safe if @post.errors.any? %>
9
9
  <div class="form-group">
10
10
  <label>Title</label>
11
- <%= f.text_field :title, class: "form-control" %>
11
+ <%= f.text_field :title, class: "form-control", name: "title" %>
12
12
  </div>
13
13
  <div class="form-group">
14
14
  <label>Description</label>
15
- <%= f.text_area :description, class: "form-control", rows: "5", cols: "10", style: "resize:none;" %>
15
+ <%= f.text_area :description, class: "form-control", rows: "5", cols: "10", style: "resize:none;", name: 'description' %>
16
16
  </div>
17
17
  <div class="form-group">
18
- <label>Created_by</label>
19
- <%= f.text_field :created_by, class: "form-control" %>
18
+ <label>Created By</label>
19
+ <%= f.text_field :created_by, class: "form-control", name: "created_by" %>
20
20
  </div>
21
21
  </p>
22
22
  </div>
@@ -1,7 +1,7 @@
1
1
  <div class="container" style="margin-top: 70px;">
2
2
  <h3>Posts</h3>
3
3
  <div style="margin-bottom: 10px;">
4
- <%= link_to 'Add User', new_post_path, class: "btn btn-success" %>
4
+ <%= link_to 'Add Post', new_post_path, class: "btn btn-success" %>
5
5
  </div>
6
6
  <table class="table table-striped">
7
7
  <thead>
@@ -21,7 +21,7 @@
21
21
  <td>
22
22
  <%= link_to 'Show', post_path(p), class: "btn btn-info" %>
23
23
  <%= link_to 'Edit', edit_post_path(p), class: "btn btn-warning"%>
24
- <%= link_to 'Delete', post_path(p), method: :delete, data: {confirm: "Are you sure?"}, :id => 'del', :remote => true, class: "btn btn-danger" %>
24
+ <%= link_to 'Delete', post_path(p), method: :delete, data: {confirm: "Are you sure?"}, :id => 'del', class: "btn btn-danger" %>
25
25
  </td>
26
26
  </tr>
27
27
  <% end %>
@@ -1,28 +1,27 @@
1
1
  <div class="container post">
2
- <%= form_for @post, url: {action: :create} do |f| %>
2
+ <%= form_for @post, url: {action: :create} do |f| %>
3
3
  <div>
4
4
  <h3>Add a Post</h3>
5
5
  </div>
6
6
  <div>
7
7
  <p>
8
- <%= "<div>#{@post.errors.full_messages.first}</div>".html_safe if @post.errors.any? %>
9
8
  <div class="form-group">
10
- <label>Title</label>
11
- <%= f.text_field :title, class: "form-control" %>
9
+ <label>Title</label>
10
+ <%= f.text_field :title, class: "form-control", name: "title" %>
12
11
  </div>
13
12
  <div class="form-group">
14
- <label>Description</label>
15
- <%= f.text_area :description, class: "form-control", rows: "5", cols: "10", style: "resize:none;" %>
13
+ <label>Description</label>
14
+ <%= f.text_area :description, class: "form-control", rows: "5", cols: "10", style: "resize:none;", name: 'description' %>
16
15
  </div>
17
16
  <div class="form-group">
18
- <label>Created_by</label>
19
- <%= f.text_field :created_by, class: "form-control" %>
17
+ <label>Created By</label>
18
+ <%= f.text_field :created_by, class: "form-control", name: "created_by" %>
20
19
  </div>
21
20
  </p>
22
21
  </div>
23
22
  <div class="row">
24
23
  <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>
24
+ <div class="col-md-4"><%= f.submit 'Create Post', class: "btn btn-success", id: "sub" %></div>
26
25
  </div>
27
26
  <% end %>
28
27
  </div>
@@ -1,4 +1,4 @@
1
- <div class="container post">
1
+ <div class="container post-1">
2
2
  <h3>Post Details</h3>
3
3
  <div>
4
4
  <label><b>Title:</b></label>
@@ -9,10 +9,10 @@
9
9
  <%= @post.description %>
10
10
  </div>
11
11
  <div>
12
- <label><b>Created_by:</b></label>
12
+ <label><b>Created By:</b></label>
13
13
  <%= @post.created_by %>
14
14
  </div>
15
- <div>
15
+ <div style="text-align: center;">
16
16
  <%= link_to 'Back', posts_path, class: "btn btn-info" %>
17
17
  </div>
18
18
  </div>
@@ -8,6 +8,13 @@
8
8
  <%= stylesheet_link_tag "form_creation/application", media: "all" %>
9
9
  <%= javascript_include_tag "form_creation/application" %>
10
10
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
11
+ <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.1/jquery.validate.min.js"></script>
12
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
13
+ <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> -->
14
+ <script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
15
+ <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
16
+ <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
17
+
11
18
  </head>
12
19
  <body>
13
20
 
@@ -1,3 +1,3 @@
1
1
  module FormCreation
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: form_creation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - madhubabu-nyros
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-14 00:00:00.000000000 Z
11
+ date: 2019-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails