form_creation 0.0.1 → 0.0.2
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/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +32 -0
- data/app/assets/config/form_creation_manifest.js +2 -0
- data/app/assets/javascripts/form_creation/application.js +15 -0
- data/app/assets/javascripts/form_creation/posts.js +2 -0
- data/app/assets/stylesheets/form_creation/application.css +15 -0
- data/app/assets/stylesheets/form_creation/posts.css +4 -0
- data/app/controllers/form_creation/application_controller.rb +5 -0
- data/app/controllers/form_creation/posts_controller.rb +65 -0
- data/app/helpers/form_creation/application_helper.rb +4 -0
- data/app/helpers/form_creation/posts_helper.rb +4 -0
- data/app/jobs/form_creation/application_job.rb +4 -0
- data/app/mailers/form_creation/application_mailer.rb +6 -0
- data/app/models/form_creation/application_record.rb +5 -0
- data/app/models/form_creation/post.rb +4 -0
- data/app/views/form_creation/posts/create.html.erb +2 -0
- data/app/views/form_creation/posts/destroy.html.erb +2 -0
- data/app/views/form_creation/posts/edit.html.erb +30 -0
- data/app/views/form_creation/posts/index.html.erb +30 -0
- data/app/views/form_creation/posts/new.html.erb +30 -0
- data/app/views/form_creation/posts/show.html.erb +2 -0
- data/app/views/form_creation/posts/update.html.erb +2 -0
- data/app/views/layouts/form_creation/application.html.erb +16 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20191014040009_create_form_creation_posts.rb +11 -0
- data/lib/form_creation.rb +5 -5
- data/lib/form_creation/engine.rb +5 -0
- data/lib/form_creation/version.rb +3 -0
- data/lib/tasks/form_creation_tasks.rake +4 -0
- metadata +68 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7defc380190a1df233c0e89273804893b1853a222cd1fdac98b125ff50c8a8b
|
4
|
+
data.tar.gz: 0de4b8788d997b90c144ce12bb46334a76623a1b995e7d34718570f77fe56da2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 880c3602ff55e25f343d87a190206cafc18f756fe48099b40deb36ce43df7f42310e308f3acc9978b90a379b98f04f53ffdc9551f2c2617822e6b196281671f6
|
7
|
+
data.tar.gz: 9bb466222e5619987bb98af6c3512bead161acab3ee38ec1a4674fbeb3f27da840bd2727b13b9aca067b4d6f6f72beb4076a7cb45892e8fa4ea6333fdf2775c3
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 madhubabu-nyros
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# FormCreation
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'form_creation'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install form_creation
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'FormCreation'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require rails-ujs
|
14
|
+
//= require activestorage
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require_dependency "form_creation/application_controller"
|
2
|
+
|
3
|
+
module FormCreation
|
4
|
+
class PostsController < ApplicationController
|
5
|
+
def index
|
6
|
+
@posts = Post.all
|
7
|
+
end
|
8
|
+
|
9
|
+
# GET method to get a Post by id
|
10
|
+
def show
|
11
|
+
@post = Post.find(params[:id])
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET method for the new Post form
|
15
|
+
def new
|
16
|
+
@post = Post.new
|
17
|
+
end
|
18
|
+
|
19
|
+
# POST method for processing form data
|
20
|
+
def create
|
21
|
+
@post = Post.new(post_params)
|
22
|
+
if @post.save
|
23
|
+
flash[:notice] = 'Post added!'
|
24
|
+
redirect_to posts_path
|
25
|
+
else
|
26
|
+
flash[:error] = 'Failed to edit Post!'
|
27
|
+
render :new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# GET method for editing a Post based on id
|
32
|
+
def edit
|
33
|
+
@post = Post.find(params[:id])
|
34
|
+
end
|
35
|
+
|
36
|
+
# PUT method for updating in database a Post based on id
|
37
|
+
def update
|
38
|
+
@post = Post.find(params[:id])
|
39
|
+
if @post.update_attributes(post_params)
|
40
|
+
flash[:notice] = 'Post updated!'
|
41
|
+
redirect_to posts_path
|
42
|
+
else
|
43
|
+
flash[:error] = 'Failed to edit Post!'
|
44
|
+
render :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# DELETE method for deleting a Post from database based on id
|
49
|
+
def destroy
|
50
|
+
@post = Post.find(params[:id])
|
51
|
+
if @post.delete
|
52
|
+
flash[:notice] = 'Post deleted!'
|
53
|
+
redirect_to posts_path
|
54
|
+
else
|
55
|
+
flash[:error] = 'Failed to delete this Post!'
|
56
|
+
render :destroy
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# we used strong parameters for the validation of params
|
61
|
+
def post_params
|
62
|
+
params.require(:post).permit(:title, :description, :created_by)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<%= form_for @post, url: {action: :update} do |f| %>
|
3
|
+
<div>
|
4
|
+
<h3>Update a Post</h3>
|
5
|
+
</div>
|
6
|
+
<div>
|
7
|
+
<p>
|
8
|
+
<%= "<div>#{@post.errors.full_messages.first}</div>".html_safe if @post.errors.any? %>
|
9
|
+
<div>
|
10
|
+
<label>Title</label>
|
11
|
+
<%= f.text_field :title %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div>
|
15
|
+
<label>Description</label>
|
16
|
+
<%= f.text_field :description %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div>
|
20
|
+
<label>Created_by</label>
|
21
|
+
<%= f.text_field :created_by %>
|
22
|
+
</div>
|
23
|
+
</p>
|
24
|
+
</div>
|
25
|
+
<div>
|
26
|
+
<%= link_to 'Back', posts_path %>
|
27
|
+
<%= f.submit 'Update Post' %>
|
28
|
+
</div>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<div class="container" style="margin-top: 70px;">
|
2
|
+
<h3>Posts</h3>
|
3
|
+
<table class="table table-striped">
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th>Title</th>
|
7
|
+
<th>Descption</th>
|
8
|
+
<th>Created_by</th>
|
9
|
+
<th>Actions</th>
|
10
|
+
</tr>
|
11
|
+
</thead>
|
12
|
+
<tbody>
|
13
|
+
<% @posts.each do |p| %>
|
14
|
+
<tr>
|
15
|
+
<td><%= p.title %></td>
|
16
|
+
<td><%= p.description %></td>
|
17
|
+
<td><%= p.created_by %></td>
|
18
|
+
<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
|
+
</td>
|
23
|
+
</tr>
|
24
|
+
<% end %>
|
25
|
+
</tbody>
|
26
|
+
</table>
|
27
|
+
</div>
|
28
|
+
<div>
|
29
|
+
<%= link_to 'Add User', new_post_path %>
|
30
|
+
</div>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<%= form_for @post, url: {action: :create} do |f| %>
|
3
|
+
<div>
|
4
|
+
<h3>Add a Post</h3>
|
5
|
+
</div>
|
6
|
+
<div>
|
7
|
+
<p>
|
8
|
+
<%= "<div>#{@post.errors.full_messages.first}</div>".html_safe if @post.errors.any? %>
|
9
|
+
<div>
|
10
|
+
<label>Title</label>
|
11
|
+
<%= f.text_field :title %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div>
|
15
|
+
<label>Description</label>
|
16
|
+
<%= f.text_field :description %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div>
|
20
|
+
<label>Created_by</label>
|
21
|
+
<%= f.text_field :created_by %>
|
22
|
+
</div>
|
23
|
+
</p>
|
24
|
+
</div>
|
25
|
+
<div>
|
26
|
+
<%= link_to 'Back', posts_path %>
|
27
|
+
<%= f.submit 'Create Post' %>
|
28
|
+
</div>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Form creation</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= stylesheet_link_tag "form_creation/application", media: "all" %>
|
9
|
+
<%= javascript_include_tag "form_creation/application" %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
|
13
|
+
<%= yield %>
|
14
|
+
|
15
|
+
</body>
|
16
|
+
</html>
|
data/config/routes.rb
ADDED
data/lib/form_creation.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
1
|
+
require "form_creation/engine"
|
2
|
+
|
3
|
+
module FormCreation
|
4
|
+
# Your code goes here...
|
5
|
+
end
|
metadata
CHANGED
@@ -1,26 +1,85 @@
|
|
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.2
|
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-
|
12
|
-
dependencies:
|
11
|
+
date: 2019-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.2.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.2.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mysql2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
description: A simple form gem
|
14
|
-
email:
|
42
|
+
email:
|
43
|
+
- madhubabu.nyros@gmail.com.com
|
15
44
|
executables: []
|
16
45
|
extensions: []
|
17
46
|
extra_rdoc_files: []
|
18
47
|
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- app/assets/config/form_creation_manifest.js
|
52
|
+
- app/assets/javascripts/form_creation/application.js
|
53
|
+
- app/assets/javascripts/form_creation/posts.js
|
54
|
+
- app/assets/stylesheets/form_creation/application.css
|
55
|
+
- app/assets/stylesheets/form_creation/posts.css
|
56
|
+
- app/controllers/form_creation/application_controller.rb
|
57
|
+
- app/controllers/form_creation/posts_controller.rb
|
58
|
+
- app/helpers/form_creation/application_helper.rb
|
59
|
+
- app/helpers/form_creation/posts_helper.rb
|
60
|
+
- app/jobs/form_creation/application_job.rb
|
61
|
+
- app/mailers/form_creation/application_mailer.rb
|
62
|
+
- app/models/form_creation/application_record.rb
|
63
|
+
- app/models/form_creation/post.rb
|
64
|
+
- app/views/form_creation/posts/create.html.erb
|
65
|
+
- app/views/form_creation/posts/destroy.html.erb
|
66
|
+
- app/views/form_creation/posts/edit.html.erb
|
67
|
+
- app/views/form_creation/posts/index.html.erb
|
68
|
+
- app/views/form_creation/posts/new.html.erb
|
69
|
+
- app/views/form_creation/posts/show.html.erb
|
70
|
+
- app/views/form_creation/posts/update.html.erb
|
71
|
+
- app/views/layouts/form_creation/application.html.erb
|
72
|
+
- config/routes.rb
|
73
|
+
- db/migrate/20191014040009_create_form_creation_posts.rb
|
19
74
|
- lib/form_creation.rb
|
20
|
-
|
75
|
+
- lib/form_creation/engine.rb
|
76
|
+
- lib/form_creation/version.rb
|
77
|
+
- lib/tasks/form_creation_tasks.rake
|
78
|
+
homepage: https://rubygems.org
|
21
79
|
licenses:
|
22
80
|
- MIT
|
23
|
-
metadata:
|
81
|
+
metadata:
|
82
|
+
allowed_push_host: https://rubygems.org
|
24
83
|
post_install_message:
|
25
84
|
rdoc_options: []
|
26
85
|
require_paths:
|
@@ -36,8 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
95
|
- !ruby/object:Gem::Version
|
37
96
|
version: '0'
|
38
97
|
requirements: []
|
39
|
-
rubygems_version: 3.0.
|
98
|
+
rubygems_version: 3.0.3
|
40
99
|
signing_key:
|
41
100
|
specification_version: 4
|
42
|
-
summary:
|
101
|
+
summary: simple form
|
43
102
|
test_files: []
|