dynamic_controller 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -4
- data/Gemfile +4 -4
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/lib/dynamic_controller/action_controller_extension.rb +17 -0
- data/lib/dynamic_controller/class_methods.rb +6 -12
- data/lib/dynamic_controller/instance_methods.rb +3 -3
- data/lib/dynamic_controller/responder.rb +1 -1
- data/lib/dynamic_controller/version.rb +1 -1
- data/lib/dynamic_controller.rb +6 -1
- data/spec/controller_factory.rb +8 -0
- data/spec/controllers/crud_actions_html_spec.rb +1 -0
- data/spec/controllers/nested_crud_actions_html_spec.rb +1 -0
- data/spec/controllers/two_level_nested_crud_actions_html_spec.rb +1 -0
- data/spec/custom_responder_format_spec.rb +13 -0
- data/spec/dummy/.gitignore +15 -15
- data/spec/dummy/Gemfile +12 -12
- data/spec/dummy/README.rdoc +261 -261
- data/spec/dummy/Rakefile +7 -7
- data/spec/dummy/app/assets/javascripts/application.js +15 -15
- data/spec/dummy/app/assets/stylesheets/application.css +13 -13
- data/spec/dummy/app/assets/stylesheets/scaffolds.css.scss +69 -69
- data/spec/dummy/app/controllers/application_controller.rb +3 -3
- data/spec/dummy/app/controllers/countries_controller.rb +86 -86
- data/spec/dummy/app/helpers/application_helper.rb +2 -2
- data/spec/dummy/app/models/country.rb +5 -5
- data/spec/dummy/app/views/cities/edit.html.erb +6 -6
- data/spec/dummy/app/views/cities/new.html.erb +5 -5
- data/spec/dummy/app/views/cities/show.html.erb +15 -15
- data/spec/dummy/app/views/countries/_form.html.erb +21 -21
- data/spec/dummy/app/views/countries/edit.html.erb +6 -6
- data/spec/dummy/app/views/countries/new.html.erb +5 -5
- data/spec/dummy/app/views/countries/show.html.erb +10 -10
- data/spec/dummy/app/views/layouts/application.html.erb +14 -14
- data/spec/dummy/config/application.rb +62 -62
- data/spec/dummy/config/boot.rb +6 -6
- data/spec/dummy/config/database.yml +25 -25
- data/spec/dummy/config/environment.rb +5 -5
- data/spec/dummy/config/environments/development.rb +37 -37
- data/spec/dummy/config/environments/production.rb +67 -67
- data/spec/dummy/config/environments/test.rb +37 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/dummy/config/initializers/inflections.rb +15 -15
- data/spec/dummy/config/initializers/mime_types.rb +5 -5
- data/spec/dummy/config/initializers/secret_token.rb +7 -7
- data/spec/dummy/config/initializers/session_store.rb +8 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
- data/spec/dummy/config/locales/en.yml +5 -5
- data/spec/dummy/config.ru +4 -4
- data/spec/dummy/db/migrate/20120907174827_create_countries.rb +9 -9
- data/spec/dummy/db/migrate/20120907230842_create_cities.rb +11 -11
- data/spec/dummy/db/seeds.rb +7 -7
- data/spec/dummy/doc/README_FOR_APP +2 -2
- data/spec/dummy/public/404.html +26 -26
- data/spec/dummy/public/422.html +26 -26
- data/spec/dummy/public/500.html +25 -25
- data/spec/dummy/public/index.html +241 -241
- data/spec/dummy/public/robots.txt +5 -5
- data/spec/dummy/script/rails +6 -6
- metadata +16 -14
data/spec/dummy/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
-
|
5
|
-
require File.expand_path('../config/application', __FILE__)
|
6
|
-
|
7
|
-
Dummy::Application.load_tasks
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -1,15 +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 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
|
-
// the compiled file.
|
9
|
-
//
|
10
|
-
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
-
// GO AFTER THE REQUIRES BELOW.
|
12
|
-
//
|
13
|
-
//= require jquery
|
14
|
-
//= require jquery_ujs
|
15
|
-
//= require_tree .
|
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
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -1,13 +1,13 @@
|
|
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 top of the
|
9
|
-
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
-
*
|
11
|
-
*= require_self
|
12
|
-
*= require_tree .
|
13
|
-
*/
|
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 top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -1,69 +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
|
-
}
|
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
|
+
}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
class ApplicationController < ActionController::Base
|
2
|
-
protect_from_forgery
|
3
|
-
end
|
1
|
+
class ApplicationController < ActionController::Base
|
2
|
+
protect_from_forgery
|
3
|
+
end
|
@@ -1,86 +1,86 @@
|
|
1
|
-
class CountriesController < ApplicationController
|
2
|
-
has_crud_actions
|
3
|
-
=begin
|
4
|
-
# GET /countries
|
5
|
-
# GET /countries.json
|
6
|
-
def index
|
7
|
-
@countries = Country.all
|
8
|
-
|
9
|
-
respond_to do |format|
|
10
|
-
format.html # index.html.erb
|
11
|
-
format.json { render json: @countries }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# GET /countries/1
|
16
|
-
# GET /countries/1.json
|
17
|
-
def show
|
18
|
-
@country = Country.find(params[:id])
|
19
|
-
|
20
|
-
respond_to do |format|
|
21
|
-
format.html # show.html.erb
|
22
|
-
format.json { render json: @country }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# GET /countries/new
|
27
|
-
# GET /countries/new.json
|
28
|
-
def new
|
29
|
-
@country = Country.new
|
30
|
-
|
31
|
-
respond_to do |format|
|
32
|
-
format.html # new.html.erb
|
33
|
-
format.json { render json: @country }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# GET /countries/1/edit
|
38
|
-
def edit
|
39
|
-
@country = Country.find(params[:id])
|
40
|
-
end
|
41
|
-
|
42
|
-
# POST /countries
|
43
|
-
# POST /countries.json
|
44
|
-
def create
|
45
|
-
@country = Country.new(params[:country])
|
46
|
-
|
47
|
-
respond_to do |format|
|
48
|
-
if @country.save
|
49
|
-
format.html { redirect_to @country, notice: 'Country was successfully created.' }
|
50
|
-
format.json { render json: @country, status: :created, location: @country }
|
51
|
-
else
|
52
|
-
format.html { render action: "new" }
|
53
|
-
format.json { render json: @country.errors, status: :unprocessable_entity }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# PUT /countries/1
|
59
|
-
# PUT /countries/1.json
|
60
|
-
def update
|
61
|
-
@country = Country.find(params[:id])
|
62
|
-
|
63
|
-
respond_to do |format|
|
64
|
-
if @country.update_attributes(params[:country])
|
65
|
-
format.html { redirect_to @country, notice: 'Country was successfully updated.' }
|
66
|
-
format.json { head :no_content }
|
67
|
-
else
|
68
|
-
format.html { render action: "edit" }
|
69
|
-
format.json { render json: @country.errors, status: :unprocessable_entity }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# DELETE /countries/1
|
75
|
-
# DELETE /countries/1.json
|
76
|
-
def destroy
|
77
|
-
@country = Country.find(params[:id])
|
78
|
-
@country.destroy
|
79
|
-
|
80
|
-
respond_to do |format|
|
81
|
-
format.html { redirect_to countries_url }
|
82
|
-
format.json { head :no_content }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
=end
|
86
|
-
end
|
1
|
+
class CountriesController < ApplicationController
|
2
|
+
has_crud_actions
|
3
|
+
=begin
|
4
|
+
# GET /countries
|
5
|
+
# GET /countries.json
|
6
|
+
def index
|
7
|
+
@countries = Country.all
|
8
|
+
|
9
|
+
respond_to do |format|
|
10
|
+
format.html # index.html.erb
|
11
|
+
format.json { render json: @countries }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /countries/1
|
16
|
+
# GET /countries/1.json
|
17
|
+
def show
|
18
|
+
@country = Country.find(params[:id])
|
19
|
+
|
20
|
+
respond_to do |format|
|
21
|
+
format.html # show.html.erb
|
22
|
+
format.json { render json: @country }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# GET /countries/new
|
27
|
+
# GET /countries/new.json
|
28
|
+
def new
|
29
|
+
@country = Country.new
|
30
|
+
|
31
|
+
respond_to do |format|
|
32
|
+
format.html # new.html.erb
|
33
|
+
format.json { render json: @country }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# GET /countries/1/edit
|
38
|
+
def edit
|
39
|
+
@country = Country.find(params[:id])
|
40
|
+
end
|
41
|
+
|
42
|
+
# POST /countries
|
43
|
+
# POST /countries.json
|
44
|
+
def create
|
45
|
+
@country = Country.new(params[:country])
|
46
|
+
|
47
|
+
respond_to do |format|
|
48
|
+
if @country.save
|
49
|
+
format.html { redirect_to @country, notice: 'Country was successfully created.' }
|
50
|
+
format.json { render json: @country, status: :created, location: @country }
|
51
|
+
else
|
52
|
+
format.html { render action: "new" }
|
53
|
+
format.json { render json: @country.errors, status: :unprocessable_entity }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# PUT /countries/1
|
59
|
+
# PUT /countries/1.json
|
60
|
+
def update
|
61
|
+
@country = Country.find(params[:id])
|
62
|
+
|
63
|
+
respond_to do |format|
|
64
|
+
if @country.update_attributes(params[:country])
|
65
|
+
format.html { redirect_to @country, notice: 'Country was successfully updated.' }
|
66
|
+
format.json { head :no_content }
|
67
|
+
else
|
68
|
+
format.html { render action: "edit" }
|
69
|
+
format.json { render json: @country.errors, status: :unprocessable_entity }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# DELETE /countries/1
|
75
|
+
# DELETE /countries/1.json
|
76
|
+
def destroy
|
77
|
+
@country = Country.find(params[:id])
|
78
|
+
@country.destroy
|
79
|
+
|
80
|
+
respond_to do |format|
|
81
|
+
format.html { redirect_to countries_url }
|
82
|
+
format.json { head :no_content }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
=end
|
86
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
module ApplicationHelper
|
2
|
-
end
|
1
|
+
module ApplicationHelper
|
2
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class Country < ActiveRecord::Base
|
2
|
-
has_many :cities, dependent: :destroy
|
3
|
-
attr_accessible :name
|
4
|
-
validates_presence_of :name
|
5
|
-
end
|
1
|
+
class Country < ActiveRecord::Base
|
2
|
+
has_many :cities, dependent: :destroy
|
3
|
+
attr_accessible :name
|
4
|
+
validates_presence_of :name
|
5
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<h1>Editing city</h1>
|
2
|
-
|
3
|
-
<%= render 'form' %>
|
4
|
-
|
5
|
-
<%= link_to 'Show', [@country, @city] %> |
|
6
|
-
<%= link_to 'Back', country_cities_path(@country) %>
|
1
|
+
<h1>Editing city</h1>
|
2
|
+
|
3
|
+
<%= render 'form' %>
|
4
|
+
|
5
|
+
<%= link_to 'Show', [@country, @city] %> |
|
6
|
+
<%= link_to 'Back', country_cities_path(@country) %>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<h1>New city</h1>
|
2
|
-
|
3
|
-
<%= render 'form' %>
|
4
|
-
|
5
|
-
<%= link_to 'Back', country_cities_path(@country) %>
|
1
|
+
<h1>New city</h1>
|
2
|
+
|
3
|
+
<%= render 'form' %>
|
4
|
+
|
5
|
+
<%= link_to 'Back', country_cities_path(@country) %>
|
@@ -1,15 +1,15 @@
|
|
1
|
-
<p id="notice"><%= notice %></p>
|
2
|
-
|
3
|
-
<p>
|
4
|
-
<b>Name:</b>
|
5
|
-
<%= @city.name %>
|
6
|
-
</p>
|
7
|
-
|
8
|
-
<p>
|
9
|
-
<b>Country:</b>
|
10
|
-
<%= @city.country.name %>
|
11
|
-
</p>
|
12
|
-
|
13
|
-
|
14
|
-
<%= link_to 'Edit', edit_country_city_path(@country, @city) %> |
|
15
|
-
<%= link_to 'Back', country_cities_path(@country) %>
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<b>Name:</b>
|
5
|
+
<%= @city.name %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<b>Country:</b>
|
10
|
+
<%= @city.country.name %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
|
14
|
+
<%= link_to 'Edit', edit_country_city_path(@country, @city) %> |
|
15
|
+
<%= link_to 'Back', country_cities_path(@country) %>
|