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 +4 -4
- data/app/assets/javascripts/form_creation/application.js +1 -0
- data/app/assets/javascripts/form_creation/posts.js +15 -0
- data/app/assets/stylesheets/form_creation/posts.css +13 -0
- data/app/controllers/form_creation/posts_controller.rb +5 -5
- data/app/models/form_creation/post.rb +4 -1
- data/app/views/form_creation/posts/edit.html.erb +4 -4
- data/app/views/form_creation/posts/index.html.erb +2 -2
- data/app/views/form_creation/posts/new.html.erb +8 -9
- data/app/views/form_creation/posts/show.html.erb +3 -3
- data/app/views/layouts/form_creation/application.html.erb +7 -0
- data/lib/form_creation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d667bd350a0a808775ceca5187d2c2f8b8dc6ef9b2bdf32ff07db2d41a35c133
|
4
|
+
data.tar.gz: e5bc3844bcab82063b94bf02cefc3a90fc590358c7c4fc55aaba6a00e6875a00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd26bc558d7e25def7668a7cba1422c412b95efc1c1f0bf508dea267870732a329b59e62cb7ce08d79c9eccf035c6bccef619fb1549a68f56b2870554b5209bd
|
7
|
+
data.tar.gz: c7e41458b6b2f529643a1916a59c4a444d5f644c675587e852e06633ed476b504203425d23b21bd8c47c2a3291883afdae53cdb3f47b44038ce452ee13f3091a
|
@@ -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.
|
62
|
+
params.permit(:title, :description, :created_by)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
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>
|
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
|
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',
|
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,
|
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
|
-
|
11
|
-
|
9
|
+
<label>Title</label>
|
10
|
+
<%= f.text_field :title, class: "form-control", name: "title" %>
|
12
11
|
</div>
|
13
12
|
<div class="form-group">
|
14
|
-
|
15
|
-
|
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>
|
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>
|
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
|
|
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.
|
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-
|
11
|
+
date: 2019-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|