link_to_add_fields 0.1.0
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +89 -0
- data/Rakefile +21 -0
- data/app/helpers/link_to_add_fields_helper.rb +26 -0
- data/lib/link_to_add_fields.rb +5 -0
- data/lib/link_to_add_fields/version.rb +3 -0
- data/lib/tasks/link_to_add_fields_tasks.rake +4 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +4 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/posts_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/comment.rb +3 -0
- data/spec/dummy/app/models/post.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/app/views/posts/_comment_fields.html.erb +8 -0
- data/spec/dummy/app/views/posts/new.html.erb +16 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +38 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +18 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +54 -0
- data/spec/dummy/config/environments/production.rb +91 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +56 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/config/secrets.yml +32 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20171003174738_create_posts.rb +9 -0
- data/spec/dummy/db/migrate/20171003174805_create_comments.rb +10 -0
- data/spec/dummy/db/migrate/20171003174822_add_body_to_posts.rb +5 -0
- data/spec/dummy/db/schema.rb +30 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +9 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/test/controllers/posts_controller_test.rb +7 -0
- data/spec/dummy/test/fixtures/comments.yml +9 -0
- data/spec/dummy/test/fixtures/posts.yml +7 -0
- data/spec/dummy/test/models/comment_test.rb +7 -0
- data/spec/dummy/test/models/post_test.rb +7 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/0Z/0ZnFgkRBKF3CIERNe7w9KUoASY_a2wk-thKxtzXr68E.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2S/2SkJj69dOzsz49h3K3zS74GvPNxBo4wdHayyfBX9SXk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/6P/6P8WXyD3Fxix1FGvEyKh-tyuueZTcm9bMYAajcoHN8A.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8N/8NTBTS9oWCuIAv30ykDIZkJuuyM-3JSN9l4SeGOlnSg.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8y/8y-IpwpOBO-lnxsTju-EygzDgN-qgF8BBc9UoJDBBkQ.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/9A/9AadUGY5iiH8NHlKET-W7IMTxozL3Z0cWgWCMlAe9jY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/9F/9FrelMC9njKNyhCC22yv3XgQnlPk0BTGX9cFc12mAZY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/9R/9Rsjy2mQW2lnBJoE9Mq8TV7ZbsNsFFjxNC8h8HmyURs.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Am/Am21CLn22T60IZnsi7sPp3dHqaaPTTtesSLW04yej2E.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Cq/CqTSaTPXbB_Tp_q4FlEf-hEQpysujPlvkE_ddiYK2P0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Dc/DcJEQpHLriCV6JMFrFwXNsiIZxNz9ruUz70XUAkAphA.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/HC/HCDOUd7-S45aJ_PjVAC_Vmjyud3i1aQv4cE3t9_Z3Dw.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/IO/IO7o1YnVKThu3g0m6Y7nUBonI8YB2cU0tr9I2xjpyBI.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/K0/K0jrFZK1m0Ar4kCZC_zhrNdAkT1KJbhq-PY39HN8mbc.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/LQ/LQsmk1MNQAUDlx3g3fw0L5D6fkFYao_SbN-_a4iWnZw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OA/OA2nUz3tXg9rzqdiLW18WUroASkm8nVyftNxAUT8u1I.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/P5/P5qnwgmL6EjMz-WcWA6hP_NfgTHV6n7_M3pTtZBdeuk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Q7/Q7Uhkdl0IQclX7LiCEPI5c8QzzdZf7MM96gVwHRA1eA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/RH/RHaIqwJm-KS0ispf6l4HySDhBDLp4DndLe7codBl3OM.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/T2/T2_JLTtw-N6zJCUsmQXFQFt99i6oUDbfIzEsj_2Wq-M.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Y3/Y3b6o1XIr8BoUiADw51O7PRhDsaQuzQRM2j2EUiDmdk.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Yc/Ycxei1ihH2r-h2kZeal0HfTT75C9gPdRZEBqzXT52Y0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_3/_3drT0Cxo20j0l7BYDrHilw_UyZIDfnnn-5rUx6ciGU.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/at/athpsrZNCGPS2SZrlxPwRuJgp1-KZVJY4dGRlSjY1v8.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bF/bFKs3lM01epQgBbJiTPkjGnhlQ8mEPdyV2cpfdpEjWk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dk/dkbk9HxcGi6dE3wvF90iLBOCy_ptOkAT0VTLdQCdNNo.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dq/dqwk-5wuKRcBAvx0WwlyEynF1Y--b9PSQmCBVCu4FbE.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hr/hrOl31BYc2VE0Ub06N_x5ZQ_Z3BtPlB2ZPj_Qq3vmHo.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iz/izY4Rrld0G1HY0btZLfiJGSNRFmiFrOL4dY0NuBAS7w.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/k4/k4nW4j_Ba8yken1q9hDeOs9D_C-2O74_xKUCTNi2dnw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m7/m75Y1VIAY2G2hlk5pqVFhHywD3yirsaLNubf0rZ91gI.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/n_/n_xYqQYhwEMQknb3jFQnjlxxBE9TzMNHCdJ-bEyZFIw.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/nx/nxTv3sKVUQZADJyM3dPaVmUA78MIsMLD_K279yN_GsI.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/o_/o_a7XvM-Hsv0bbPOjiev00bxzNBC8Mk9F_Yt3wod5GE.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pW/pWeTmc08P_nBIO2TNDsru9GQspuB-gaTKWAX8QE0QoY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/qP/qPmv5snMrDw830S6hSICDcnIy7kVEWoFKXhGKT38lG4.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sC/sCthqsbGZqQt7PDs-oOuF4Z65pm0kXC7t1XJ0vgsI3A.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sL/sL2IsvsBcUjNu1AGqskXkgCDV3w8K36u932CwS6xjFc.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/uI/uI1AF78tmzya0Zszf_FSnZ8jvB8xQFeVSi97HlhRrjg.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/v0/v0_mKvWqZ2mSYGaC4PyWEY_b9mPzfAcoEsIgF9UBfWU.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/va/va5E0m3hAgsYn1xgi2zGWYw7rKpEt5-t7lEB1-ABo-w.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/vi/viXCeETYVtGmRy9Aon8XHad7Vr9knlEz46T4Iao12LI.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wn/wnA33hYNNCXl7o1S-ccNre_u1xucJotamaE1eu3JLnQ.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yI/yI2QGugA1jmXtaVF-Yz45sXJ6rR3M-zZ5gPxJWHPr74.cache +3 -0
- data/spec/features/link_to_add_fields_spec.rb +54 -0
- data/spec/spec_helper.rb +19 -0
- data/vendor/assets/javascripts/link_to_add_fields.js +21 -0
- metadata +365 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b8033fcfe31d3cfb7852d44afde60305123cc120
|
4
|
+
data.tar.gz: b42164453f26a98699a5641b67dbc1cc64f768b3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bdd1136c834105f39400c2c2d77e225b455ff7b2aa11be17968f5b5e7caaa7e5099623de7f48468a0d43856dfdaf4eccd536462146db214307a173e4ab56ba81
|
7
|
+
data.tar.gz: 5ddec37e0ae37edc25f5d5c26839da19b081015b6e95d38bcda0eaea0359951de376960b13070912a9d6ad9212ae5887d07b43b9e026c951981ae4ba44930215
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 richard lynch
|
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,89 @@
|
|
1
|
+
# LinkToAddFields
|
2
|
+

|
3
|
+
|
4
|
+
Dynamically add nested fields to your Rails forms.
|
5
|
+
When clicked, `link_to_add_fields` will render the association's fields partial
|
6
|
+
above it.
|
7
|
+
`link_to_remove_fields` will hide the HTML element matching it's
|
8
|
+
target css selector. It also sets a truthy value in the hidden input field
|
9
|
+
closest to it, name this field `_destroy` to remove models.
|
10
|
+
|
11
|
+
After seeing this idea in a Rails casts episode I ended up using it so often I
|
12
|
+
thought it worth making a gem.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
Make sure you have jQuery installed.
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
```ruby
|
19
|
+
gem 'link_to_add_fields'
|
20
|
+
```
|
21
|
+
|
22
|
+
Then execute:
|
23
|
+
```bash
|
24
|
+
$ bundle
|
25
|
+
```
|
26
|
+
|
27
|
+
And require `link_to_add_fields` in application.js, after jQuery.
|
28
|
+
```javascript
|
29
|
+
//
|
30
|
+
//= require jquery
|
31
|
+
//= require link_to_add_fields
|
32
|
+
//= require_tree .
|
33
|
+
|
34
|
+
```
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
### `link_to_add_fields(name, builder, association, options = {}) => String`
|
38
|
+
#### Parameters:
|
39
|
+
- name (String) -- Name of the link, passed to `link_to`.
|
40
|
+
- builder (ActionView::Helpers::FormBuilder) -- Parent form builder object.
|
41
|
+
- association (Symbol) -- Child association name (pluralised).
|
42
|
+
- options (Hash) (defaults to: {}) -- a customizable set of options.
|
43
|
+
#### Options Hash (options):
|
44
|
+
- :partial (String) -- Path to partial, override the inferred partial. If left
|
45
|
+
blank will be inferred form the form's model's name and the association
|
46
|
+
(signularised), eg `posts/comment_fields`
|
47
|
+
- other options are passed through to `link_to`.
|
48
|
+
|
49
|
+
### `link_to_remove_fields(name, target, options = {}) => String`
|
50
|
+
#### Parameters:
|
51
|
+
- name (String) -- Name of the link, passed to `link_to`.
|
52
|
+
- target (String) -- Css selector to hide.
|
53
|
+
- options (Hash) (defaults to: {}) -- a customizable set of options.
|
54
|
+
#### Options Hash (options):
|
55
|
+
- other options are passed through to `link_to`.
|
56
|
+
|
57
|
+
## Example
|
58
|
+
`post_form.html.erb`
|
59
|
+
```erb
|
60
|
+
<%= form_for @post do |f| %>
|
61
|
+
<%= f.label :name %>
|
62
|
+
<%= f.text_field :name %><br>
|
63
|
+
|
64
|
+
<%= f.label :body %>
|
65
|
+
<%= f.text_area :body %><br>
|
66
|
+
|
67
|
+
<%= f.fields_for :comments do |ff| %>
|
68
|
+
<%= render partial: "comment_fields", locals: { f: ff } %>
|
69
|
+
<br>
|
70
|
+
<% end %>
|
71
|
+
|
72
|
+
<%= link_to_add_fields 'Add comment', f, :comments %><br>
|
73
|
+
|
74
|
+
<%= f.submit %>
|
75
|
+
<% end %>
|
76
|
+
```
|
77
|
+
`comment_fields.html.erb`
|
78
|
+
```erb
|
79
|
+
<div class="comment_fields">
|
80
|
+
<%= f.label :body, 'Comment' %>
|
81
|
+
<%= f.text_area :body %><br>
|
82
|
+
|
83
|
+
<%= f.hidden_field :_destroy %>
|
84
|
+
<%= link_to_remove_fields 'Remove comment', '.comment_fields' %>
|
85
|
+
</div>
|
86
|
+
```
|
87
|
+
|
88
|
+
## License
|
89
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
9
|
+
load 'rails/tasks/engine.rake'
|
10
|
+
|
11
|
+
Bundler::GemHelper.install_tasks
|
12
|
+
|
13
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
14
|
+
|
15
|
+
require 'rspec/core'
|
16
|
+
require 'rspec/core/rake_task'
|
17
|
+
|
18
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
19
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
20
|
+
|
21
|
+
task :default => :spec
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module LinkToAddFieldsHelper
|
2
|
+
def link_to_add_fields(name, f, association, options = {})
|
3
|
+
new_object = f.object.send(association).klass.new
|
4
|
+
id = new_object.object_id
|
5
|
+
objects_name = f.object.class.name.underscore.pluralize
|
6
|
+
options_partial = options.delete(:partial)
|
7
|
+
infered_partial = association.to_s.singularize + "_fields"
|
8
|
+
partial_name = options_partial || infered_partial
|
9
|
+
template_name = "#{objects_name}/#{partial_name}"
|
10
|
+
fields = f.fields_for(association, new_object, child_index: id) do |builder|
|
11
|
+
render(template_name, f: builder)
|
12
|
+
end
|
13
|
+
data = options[:data] || {}
|
14
|
+
options[:data] = data.merge(
|
15
|
+
link_to_add_field_id: id,
|
16
|
+
link_to_add_field: fields.gsub("\n", "")
|
17
|
+
)
|
18
|
+
link_to name, '#', options
|
19
|
+
end
|
20
|
+
|
21
|
+
def link_to_remove_fields(name, target, options = {})
|
22
|
+
data = options[:data] || {}
|
23
|
+
options[:data] = data.merge(link_to_remove_field: target)
|
24
|
+
link_to name, '#', options
|
25
|
+
end
|
26
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -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 jquery
|
14
|
+
//= require link_to_add_fields
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
@@ -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 @@
|
|
1
|
+
<%= yield %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%= form_for @post do |f| %>
|
2
|
+
<%= f.label :name %>
|
3
|
+
<br>
|
4
|
+
<%= f.text_field :name %>
|
5
|
+
<br>
|
6
|
+
<%= f.label :body %>
|
7
|
+
<br>
|
8
|
+
<%= f.text_area :body %>
|
9
|
+
<%= f.fields_for :comments do |ff| %>
|
10
|
+
<%= render partial: "comment_fields", locals: { f: ff } %>
|
11
|
+
<% end %>
|
12
|
+
<br>
|
13
|
+
<%= link_to_add_fields 'Add comment', f, :comments, class: 'btn', data: { test: true } %>
|
14
|
+
<br>
|
15
|
+
<%= f.submit %>
|
16
|
+
<% end %>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a starting point to setup your application.
|
15
|
+
# Add necessary setup steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
# Install JavaScript dependencies if using Yarn
|
22
|
+
# system('bin/yarn')
|
23
|
+
|
24
|
+
|
25
|
+
# puts "\n== Copying sample files =="
|
26
|
+
# unless File.exist?('config/database.yml')
|
27
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
28
|
+
# end
|
29
|
+
|
30
|
+
puts "\n== Preparing database =="
|
31
|
+
system! 'bin/rails db:setup'
|
32
|
+
|
33
|
+
puts "\n== Removing old logs and tempfiles =="
|
34
|
+
system! 'bin/rails log:clear tmp:clear'
|
35
|
+
|
36
|
+
puts "\n== Restarting application server =="
|
37
|
+
system! 'bin/rails restart'
|
38
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a way to update your development environment automatically.
|
15
|
+
# Add necessary update steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
puts "\n== Updating database =="
|
22
|
+
system! 'bin/rails db:migrate'
|
23
|
+
|
24
|
+
puts "\n== Removing old logs and tempfiles =="
|
25
|
+
system! 'bin/rails log:clear tmp:clear'
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system! 'bin/rails restart'
|
29
|
+
end
|