activerecord-refresh_connection 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +14 -0
- data/activerecord-refresh_connection.gemspec +27 -0
- data/example/.gitignore +16 -0
- data/example/Gemfile +41 -0
- data/example/README.rdoc +28 -0
- data/example/Rakefile +6 -0
- data/example/app/assets/images/.keep +0 -0
- data/example/app/assets/javascripts/application.js +16 -0
- data/example/app/assets/javascripts/articles.js.coffee +3 -0
- data/example/app/assets/javascripts/books.js.coffee +3 -0
- data/example/app/assets/stylesheets/application.css +15 -0
- data/example/app/assets/stylesheets/articles.css.scss +3 -0
- data/example/app/assets/stylesheets/books.css.scss +3 -0
- data/example/app/assets/stylesheets/scaffolds.css.scss +69 -0
- data/example/app/controllers/application_controller.rb +5 -0
- data/example/app/controllers/articles_controller.rb +74 -0
- data/example/app/controllers/books_controller.rb +74 -0
- data/example/app/controllers/concerns/.keep +0 -0
- data/example/app/helpers/application_helper.rb +2 -0
- data/example/app/helpers/articles_helper.rb +2 -0
- data/example/app/helpers/books_helper.rb +2 -0
- data/example/app/mailers/.keep +0 -0
- data/example/app/models/.keep +0 -0
- data/example/app/models/article.rb +2 -0
- data/example/app/models/book.rb +2 -0
- data/example/app/models/concerns/.keep +0 -0
- data/example/app/views/articles/_form.html.erb +21 -0
- data/example/app/views/articles/edit.html.erb +6 -0
- data/example/app/views/articles/index.html.erb +25 -0
- data/example/app/views/articles/index.json.jbuilder +4 -0
- data/example/app/views/articles/new.html.erb +5 -0
- data/example/app/views/articles/show.html.erb +9 -0
- data/example/app/views/articles/show.json.jbuilder +1 -0
- data/example/app/views/books/_form.html.erb +21 -0
- data/example/app/views/books/edit.html.erb +6 -0
- data/example/app/views/books/index.html.erb +25 -0
- data/example/app/views/books/index.json.jbuilder +4 -0
- data/example/app/views/books/new.html.erb +5 -0
- data/example/app/views/books/show.html.erb +9 -0
- data/example/app/views/books/show.json.jbuilder +1 -0
- data/example/app/views/layouts/application.html.erb +14 -0
- data/example/bin/bundle +3 -0
- data/example/bin/rails +4 -0
- data/example/bin/rake +4 -0
- data/example/config.ru +4 -0
- data/example/config/application.rb +26 -0
- data/example/config/boot.rb +4 -0
- data/example/config/database.yml +18 -0
- data/example/config/environment.rb +5 -0
- data/example/config/environments/development.rb +37 -0
- data/example/config/environments/production.rb +83 -0
- data/example/config/environments/test.rb +39 -0
- data/example/config/initializers/backtrace_silencers.rb +7 -0
- data/example/config/initializers/cookies_serializer.rb +3 -0
- data/example/config/initializers/filter_parameter_logging.rb +4 -0
- data/example/config/initializers/inflections.rb +16 -0
- data/example/config/initializers/mime_types.rb +4 -0
- data/example/config/initializers/session_store.rb +3 -0
- data/example/config/initializers/wrap_parameters.rb +14 -0
- data/example/config/locales/en.yml +23 -0
- data/example/config/routes.rb +60 -0
- data/example/config/secrets.yml +22 -0
- data/example/db/migrate/20140623044349_create_books.rb +9 -0
- data/example/db/migrate/20140623044357_create_articles.rb +9 -0
- data/example/db/schema.rb +28 -0
- data/example/db/seeds.rb +7 -0
- data/example/lib/assets/.keep +0 -0
- data/example/lib/tasks/.keep +0 -0
- data/example/log/.keep +0 -0
- data/example/public/404.html +67 -0
- data/example/public/422.html +67 -0
- data/example/public/500.html +66 -0
- data/example/public/favicon.ico +0 -0
- data/example/public/robots.txt +5 -0
- data/example/test/controllers/.keep +0 -0
- data/example/test/controllers/articles_controller_test.rb +49 -0
- data/example/test/controllers/books_controller_test.rb +49 -0
- data/example/test/fixtures/.keep +0 -0
- data/example/test/fixtures/articles.yml +7 -0
- data/example/test/fixtures/books.yml +7 -0
- data/example/test/helpers/.keep +0 -0
- data/example/test/helpers/articles_helper_test.rb +4 -0
- data/example/test/helpers/books_helper_test.rb +4 -0
- data/example/test/integration/.keep +0 -0
- data/example/test/mailers/.keep +0 -0
- data/example/test/models/.keep +0 -0
- data/example/test/models/article_test.rb +7 -0
- data/example/test/models/book_test.rb +7 -0
- data/example/test/test_helper.rb +13 -0
- data/example/vendor/assets/javascripts/.keep +0 -0
- data/example/vendor/assets/stylesheets/.keep +0 -0
- data/lib/activerecord-refresh_connection.rb +1 -0
- data/lib/activerecord-refresh_connection/active_record/connection_adapters/refresh_connection_management.rb +24 -0
- data/spec/spec_helper.rb +15 -0
- metadata +229 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 52a01f4786ed07aa416bbd7e9bdb9af656fd2b77
|
4
|
+
data.tar.gz: f213332480d2531baaea3352bfca9547573b825c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 056a7d5b883e637ecf7fb75bed37bb279ab9f4b3f5b75453628b6c1b8dfa96a86dcc8461e579696de83f56dbb705bd8d94ddff36532f4cd646f255e6e7f5b89d
|
7
|
+
data.tar.gz: 85514a7826551be9fe120d49a8ddc343bdfe109aba2f1bb485bb94c4728ed79101295508c2b6fb5b892f2087e7c0c2f1c532a56e3ad2456f843577e6a948663d
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.ruby-version
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Naotoshi Seo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# activerecord-refresh_connection
|
2
|
+
|
3
|
+
|
4
|
+
[![Build Status](https://secure.travis-ci.org/sonots/activerecord-refresh_connection.png?branch=master)](http://travis-ci.org/sonots/activerecord-refresh_connection)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/sonots/activerecord-refresh_connection/badge.png?branch=master)](https://coveralls.io/r/sonots/activerecord-refresh_connection?branch=master)
|
6
|
+
|
7
|
+
Refresh ActiveRecord connection on each rack request
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add the following to your `Gemfile`:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'activerecord-refresh_connection'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
```plain
|
20
|
+
$ bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
## How to Use
|
24
|
+
|
25
|
+
This gem provides a rack middleware `ActiveRecord::ConnectionAdapters::RefreshConnectionManagement` which disconnects all connections in each rack request.
|
26
|
+
|
27
|
+
### Rails
|
28
|
+
|
29
|
+
Swap the default rails ConnectionManagement.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# config/application.rb
|
33
|
+
require 'activerecord-refresh_connection'
|
34
|
+
|
35
|
+
class Application < Rails::Application
|
36
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
37
|
+
config.middleware.swap ActiveRecord::ConnectionAdapters::ConnectionManagement,
|
38
|
+
"ActiveRecord::ConnectionAdapters::RefreshConnectionManagement"
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
Middleware check.
|
43
|
+
|
44
|
+
```bash
|
45
|
+
bundle exec rake middleware
|
46
|
+
```
|
47
|
+
|
48
|
+
### Sinatra
|
49
|
+
|
50
|
+
To Be Written
|
51
|
+
|
52
|
+
## ChangeLog
|
53
|
+
|
54
|
+
See [CHANGELOG.md](CHANGELOG.md) for details.
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
1. Fork it
|
59
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
60
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
62
|
+
5. Create new [Pull Request](../../pull/new/master)
|
63
|
+
|
64
|
+
## Copyright
|
65
|
+
|
66
|
+
Copyright (c) 2014 Naotoshi Seo. See [LICENSE.txt](LICENSE.txt) for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rspec/core'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
6
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
7
|
+
end
|
8
|
+
task :default => :spec
|
9
|
+
|
10
|
+
desc 'Open an irb session preloaded with the gem library'
|
11
|
+
task :console do
|
12
|
+
sh 'irb -rubygems -I lib -r sql-maker'
|
13
|
+
end
|
14
|
+
task :c => :console
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "activerecord-refresh_connection"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Naotoshi Seo"]
|
9
|
+
spec.email = ["sonots@gmail.com"]
|
10
|
+
spec.summary = %q{Refresh ActiveRecord connection on each rack request}
|
11
|
+
spec.description = %q{Refresh ActiveRecord connection on each rack request.}
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency "activerecord"
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
spec.add_development_dependency "pry-nav"
|
27
|
+
end
|
data/example/.gitignore
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-journal
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*.log
|
16
|
+
/tmp
|
data/example/Gemfile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'activerecord-refresh_connection', path: '../'
|
4
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
5
|
+
gem 'rails', '4.1.1'
|
6
|
+
# Use sqlite3 as the database for Active Record
|
7
|
+
# gem 'sqlite3'
|
8
|
+
gem 'mysql2'
|
9
|
+
# Use SCSS for stylesheets
|
10
|
+
gem 'sass-rails', '~> 4.0.3'
|
11
|
+
# Use Uglifier as compressor for JavaScript assets
|
12
|
+
gem 'uglifier', '>= 1.3.0'
|
13
|
+
# Use CoffeeScript for .js.coffee assets and views
|
14
|
+
gem 'coffee-rails', '~> 4.0.0'
|
15
|
+
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
16
|
+
# gem 'therubyracer', platforms: :ruby
|
17
|
+
|
18
|
+
# Use jquery as the JavaScript library
|
19
|
+
gem 'jquery-rails'
|
20
|
+
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
21
|
+
gem 'turbolinks'
|
22
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
23
|
+
gem 'jbuilder', '~> 2.0'
|
24
|
+
# bundle exec rake doc:rails generates the API under doc/api.
|
25
|
+
gem 'sdoc', '~> 0.4.0', group: :doc
|
26
|
+
|
27
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
28
|
+
gem 'spring', group: :development
|
29
|
+
|
30
|
+
# Use ActiveModel has_secure_password
|
31
|
+
# gem 'bcrypt', '~> 3.1.7'
|
32
|
+
|
33
|
+
# Use unicorn as the app server
|
34
|
+
# gem 'unicorn'
|
35
|
+
|
36
|
+
# Use Capistrano for deployment
|
37
|
+
# gem 'capistrano-rails', group: :development
|
38
|
+
|
39
|
+
# Use debugger
|
40
|
+
# gem 'debugger', group: [:development, :test]
|
41
|
+
|
data/example/README.rdoc
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/example/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,16 @@
|
|
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 vendor/assets/javascripts of plugins, if any, 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.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require turbolinks
|
16
|
+
//= 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 vendor/assets/stylesheets of plugins, if any, 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 styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,69 @@
|
|
1
|
+
body {
|
2
|
+
background-color: #fff;
|
3
|
+
color: #333;
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
p, ol, ul, td {
|
10
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
11
|
+
font-size: 13px;
|
12
|
+
line-height: 18px;
|
13
|
+
}
|
14
|
+
|
15
|
+
pre {
|
16
|
+
background-color: #eee;
|
17
|
+
padding: 10px;
|
18
|
+
font-size: 11px;
|
19
|
+
}
|
20
|
+
|
21
|
+
a {
|
22
|
+
color: #000;
|
23
|
+
&:visited {
|
24
|
+
color: #666;
|
25
|
+
}
|
26
|
+
&:hover {
|
27
|
+
color: #fff;
|
28
|
+
background-color: #000;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
div {
|
33
|
+
&.field, &.actions {
|
34
|
+
margin-bottom: 10px;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
#notice {
|
39
|
+
color: green;
|
40
|
+
}
|
41
|
+
|
42
|
+
.field_with_errors {
|
43
|
+
padding: 2px;
|
44
|
+
background-color: red;
|
45
|
+
display: table;
|
46
|
+
}
|
47
|
+
|
48
|
+
#error_explanation {
|
49
|
+
width: 450px;
|
50
|
+
border: 2px solid red;
|
51
|
+
padding: 7px;
|
52
|
+
padding-bottom: 0;
|
53
|
+
margin-bottom: 20px;
|
54
|
+
background-color: #f0f0f0;
|
55
|
+
h2 {
|
56
|
+
text-align: left;
|
57
|
+
font-weight: bold;
|
58
|
+
padding: 5px 5px 5px 15px;
|
59
|
+
font-size: 12px;
|
60
|
+
margin: -7px;
|
61
|
+
margin-bottom: 0px;
|
62
|
+
background-color: #c00;
|
63
|
+
color: #fff;
|
64
|
+
}
|
65
|
+
ul li {
|
66
|
+
font-size: 12px;
|
67
|
+
list-style: square;
|
68
|
+
}
|
69
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
class ArticlesController < ApplicationController
|
2
|
+
before_action :set_article, only: [:show, :edit, :update, :destroy]
|
3
|
+
|
4
|
+
# GET /articles
|
5
|
+
# GET /articles.json
|
6
|
+
def index
|
7
|
+
@articles = Article.all
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /articles/1
|
11
|
+
# GET /articles/1.json
|
12
|
+
def show
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /articles/new
|
16
|
+
def new
|
17
|
+
@article = Article.new
|
18
|
+
end
|
19
|
+
|
20
|
+
# GET /articles/1/edit
|
21
|
+
def edit
|
22
|
+
end
|
23
|
+
|
24
|
+
# POST /articles
|
25
|
+
# POST /articles.json
|
26
|
+
def create
|
27
|
+
@article = Article.new(article_params)
|
28
|
+
|
29
|
+
respond_to do |format|
|
30
|
+
if @article.save
|
31
|
+
format.html { redirect_to @article, notice: 'Article was successfully created.' }
|
32
|
+
format.json { render :show, status: :created, location: @article }
|
33
|
+
else
|
34
|
+
format.html { render :new }
|
35
|
+
format.json { render json: @article.errors, status: :unprocessable_entity }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# PATCH/PUT /articles/1
|
41
|
+
# PATCH/PUT /articles/1.json
|
42
|
+
def update
|
43
|
+
respond_to do |format|
|
44
|
+
if @article.update(article_params)
|
45
|
+
format.html { redirect_to @article, notice: 'Article was successfully updated.' }
|
46
|
+
format.json { render :show, status: :ok, location: @article }
|
47
|
+
else
|
48
|
+
format.html { render :edit }
|
49
|
+
format.json { render json: @article.errors, status: :unprocessable_entity }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# DELETE /articles/1
|
55
|
+
# DELETE /articles/1.json
|
56
|
+
def destroy
|
57
|
+
@article.destroy
|
58
|
+
respond_to do |format|
|
59
|
+
format.html { redirect_to articles_url, notice: 'Article was successfully destroyed.' }
|
60
|
+
format.json { head :no_content }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
# Use callbacks to share common setup or constraints between actions.
|
66
|
+
def set_article
|
67
|
+
@article = Article.find(params[:id])
|
68
|
+
end
|
69
|
+
|
70
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
71
|
+
def article_params
|
72
|
+
params.require(:article).permit(:title)
|
73
|
+
end
|
74
|
+
end
|