dynamic_controller 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.
Files changed (91) hide show
  1. data/.gitignore +4 -4
  2. data/Gemfile +4 -4
  3. data/README.md +39 -2
  4. data/Rakefile +1 -1
  5. data/dynamic_controller.gemspec +26 -26
  6. data/lib/dynamic_controller/class_methods.rb +48 -0
  7. data/lib/dynamic_controller/helper_methods.rb +59 -0
  8. data/lib/dynamic_controller/instance_methods.rb +127 -0
  9. data/lib/dynamic_controller/resource.rb +21 -0
  10. data/lib/dynamic_controller/responder.rb +71 -0
  11. data/lib/dynamic_controller/version.rb +3 -3
  12. data/lib/dynamic_controller.rb +12 -180
  13. data/spec/controller_factory.rb +15 -0
  14. data/spec/controllers/crud_actions_json_spec.rb +3 -3
  15. data/spec/controllers/nested_crud_actions_html_spec.rb +9 -8
  16. data/spec/controllers/nested_crud_actions_json_spec.rb +11 -11
  17. data/spec/controllers/redefined_responders_html_spec.rb +112 -0
  18. data/spec/controllers/redefined_responders_json_spec.rb +95 -0
  19. data/spec/controllers/two_level_nested_crud_actions_html_spec.rb +134 -0
  20. data/spec/controllers/two_level_nested_crud_actions_json_spec.rb +98 -0
  21. data/spec/dummy/.gitignore +15 -15
  22. data/spec/dummy/Gemfile +12 -12
  23. data/spec/dummy/README.rdoc +261 -261
  24. data/spec/dummy/Rakefile +7 -7
  25. data/spec/dummy/app/assets/javascripts/application.js +15 -15
  26. data/spec/dummy/app/assets/stylesheets/application.css +13 -13
  27. data/spec/dummy/app/assets/stylesheets/scaffolds.css.scss +69 -69
  28. data/spec/dummy/app/controllers/application_controller.rb +3 -3
  29. data/spec/dummy/app/controllers/cities_controller.rb +95 -94
  30. data/spec/dummy/app/controllers/countries_controller.rb +86 -86
  31. data/spec/dummy/app/controllers/languages_controller.rb +95 -0
  32. data/spec/dummy/app/controllers/streets_controller.rb +97 -0
  33. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  34. data/spec/dummy/app/models/city.rb +6 -5
  35. data/spec/dummy/app/models/country.rb +5 -5
  36. data/spec/dummy/app/models/language.rb +4 -0
  37. data/spec/dummy/app/models/street.rb +5 -0
  38. data/spec/dummy/app/views/cities/_form.html.erb +25 -25
  39. data/spec/dummy/app/views/cities/edit.html.erb +6 -6
  40. data/spec/dummy/app/views/cities/index.html.erb +29 -25
  41. data/spec/dummy/app/views/cities/new.html.erb +5 -5
  42. data/spec/dummy/app/views/cities/show.html.erb +15 -15
  43. data/spec/dummy/app/views/countries/_form.html.erb +21 -21
  44. data/spec/dummy/app/views/countries/edit.html.erb +6 -6
  45. data/spec/dummy/app/views/countries/index.html.erb +25 -23
  46. data/spec/dummy/app/views/countries/new.html.erb +5 -5
  47. data/spec/dummy/app/views/countries/show.html.erb +10 -10
  48. data/spec/dummy/app/views/languages/_form.html.erb +21 -0
  49. data/spec/dummy/app/views/languages/edit.html.erb +6 -0
  50. data/spec/dummy/app/views/languages/index.html.erb +23 -0
  51. data/spec/dummy/app/views/languages/new.html.erb +5 -0
  52. data/spec/dummy/app/views/languages/show.html.erb +10 -0
  53. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  54. data/spec/dummy/app/views/streets/_form.html.erb +25 -0
  55. data/spec/dummy/app/views/streets/edit.html.erb +6 -0
  56. data/spec/dummy/app/views/streets/index.html.erb +27 -0
  57. data/spec/dummy/app/views/streets/new.html.erb +5 -0
  58. data/spec/dummy/app/views/streets/show.html.erb +15 -0
  59. data/spec/dummy/config/application.rb +62 -62
  60. data/spec/dummy/config/boot.rb +6 -6
  61. data/spec/dummy/config/database.yml +25 -25
  62. data/spec/dummy/config/environment.rb +5 -5
  63. data/spec/dummy/config/environments/development.rb +37 -37
  64. data/spec/dummy/config/environments/production.rb +67 -67
  65. data/spec/dummy/config/environments/test.rb +37 -37
  66. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  67. data/spec/dummy/config/initializers/inflections.rb +15 -15
  68. data/spec/dummy/config/initializers/mime_types.rb +5 -5
  69. data/spec/dummy/config/initializers/secret_token.rb +7 -7
  70. data/spec/dummy/config/initializers/session_store.rb +8 -8
  71. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  72. data/spec/dummy/config/locales/en.yml +5 -5
  73. data/spec/dummy/config/routes.rb +8 -5
  74. data/spec/dummy/config.ru +4 -4
  75. data/spec/dummy/db/migrate/20120907174827_create_countries.rb +9 -9
  76. data/spec/dummy/db/migrate/20120907230842_create_cities.rb +11 -11
  77. data/spec/dummy/db/migrate/20120922010743_create_languages.rb +9 -0
  78. data/spec/dummy/db/migrate/20120929185302_create_streets.rb +11 -0
  79. data/spec/dummy/db/schema.rb +16 -1
  80. data/spec/dummy/db/seeds.rb +7 -7
  81. data/spec/dummy/doc/README_FOR_APP +2 -2
  82. data/spec/dummy/public/404.html +26 -26
  83. data/spec/dummy/public/422.html +26 -26
  84. data/spec/dummy/public/500.html +25 -25
  85. data/spec/dummy/public/index.html +241 -241
  86. data/spec/dummy/public/robots.txt +5 -5
  87. data/spec/dummy/script/rails +6 -6
  88. data/spec/factories.rb +9 -0
  89. data/spec/has_crud_actions_options_spec.rb +49 -0
  90. data/spec/spec_helper.rb +1 -0
  91. metadata +43 -16
@@ -0,0 +1,97 @@
1
+ class StreetsController < ApplicationController
2
+ has_crud_actions
3
+ nested_of Country
4
+ nested_of City
5
+ =begin
6
+ before_filter :load_nested
7
+
8
+ # GET /streets
9
+ # GET /streets.json
10
+ def index
11
+ @streets = @city.streets
12
+
13
+ respond_to do |format|
14
+ format.html # index.html.erb
15
+ format.json { render json: @streets }
16
+ end
17
+ end
18
+
19
+ # GET /streets/1
20
+ # GET /streets/1.json
21
+ def show
22
+ @street = @city.streets.find(params[:id])
23
+
24
+ respond_to do |format|
25
+ format.html # show.html.erb
26
+ format.json { render json: @street }
27
+ end
28
+ end
29
+
30
+ # GET /streets/new
31
+ # GET /streets/new.json
32
+ def new
33
+ @street = @city.streets.build
34
+
35
+ respond_to do |format|
36
+ format.html # new.html.erb
37
+ format.json { render json: @street }
38
+ end
39
+ end
40
+
41
+ # GET /streets/1/edit
42
+ def edit
43
+ @street = @city.streets.find(params[:id])
44
+ end
45
+
46
+ # POST /streets
47
+ # POST /streets.json
48
+ def create
49
+ @street = @city.streets.build(params[:street])
50
+
51
+ respond_to do |format|
52
+ if @street.save
53
+ format.html { redirect_to [@country, @city, @street], notice: 'Street was successfully created.' }
54
+ format.json { render json: @street, status: :created }
55
+ else
56
+ format.html { render action: "new" }
57
+ format.json { render json: @street.errors, status: :unprocessable_entity }
58
+ end
59
+ end
60
+ end
61
+
62
+ # PUT /streets/1
63
+ # PUT /streets/1.json
64
+ def update
65
+ @street = @city.streets.find(params[:id])
66
+
67
+ respond_to do |format|
68
+ if @street.update_attributes(params[:street])
69
+ format.html { redirect_to [@country, @city, @street], notice: 'Street was successfully updated.' }
70
+ format.json { head :no_content }
71
+ else
72
+ format.html { render action: "edit" }
73
+ format.json { render json: @street.errors, status: :unprocessable_entity }
74
+ end
75
+ end
76
+ end
77
+
78
+ # DELETE /streets/1
79
+ # DELETE /streets/1.json
80
+ def destroy
81
+ @street = @city.streets.find(params[:id])
82
+ @street.destroy
83
+
84
+ respond_to do |format|
85
+ format.html { redirect_to country_city_streets_url(@country, @city) }
86
+ format.json { head :no_content }
87
+ end
88
+ end
89
+
90
+ private
91
+
92
+ def load_nested
93
+ @country = Country.find(params[:country_id])
94
+ @city = @country.cities.find(params[:city_id])
95
+ end
96
+ =end
97
+ end
@@ -1,2 +1,2 @@
1
- module ApplicationHelper
2
- end
1
+ module ApplicationHelper
2
+ end
@@ -1,5 +1,6 @@
1
- class City < ActiveRecord::Base
2
- belongs_to :country
3
- attr_accessible :country_id, :name
4
- validates_presence_of :country_id, :name
5
- end
1
+ class City < ActiveRecord::Base
2
+ belongs_to :country
3
+ has_many :streets, dependent: :destroy
4
+ attr_accessible :country_id, :name
5
+ validates_presence_of :country_id, :name
6
+ 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
@@ -0,0 +1,4 @@
1
+ class Language < ActiveRecord::Base
2
+ attr_accessible :name
3
+ validates_presence_of :name
4
+ end
@@ -0,0 +1,5 @@
1
+ class Street < ActiveRecord::Base
2
+ belongs_to :city
3
+ attr_accessible :city_id, :name
4
+ validates_presence_of :city_id, :name
5
+ end
@@ -1,25 +1,25 @@
1
- <%= form_for([@country, @city]) do |f| %>
2
- <% if @city.errors.any? %>
3
- <div id="error_explanation">
4
- <h2><%= pluralize(@city.errors.count, "error") %> prohibited this city from being saved:</h2>
5
-
6
- <ul>
7
- <% @city.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <div class="field">
15
- <%= f.label :name %><br />
16
- <%= f.text_field :name %>
17
- </div>
18
- <div class="field">
19
- <%= f.label :country %><br />
20
- <%= f.select :country_id, Country.scoped.map{|c| [c.name, c.id]}, prompt: '[Select]' %>
21
- </div>
22
- <div class="actions">
23
- <%= f.submit %>
24
- </div>
25
- <% end %>
1
+ <%= form_for([@country, @city]) do |f| %>
2
+ <% if @city.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@city.errors.count, "error") %> prohibited this city from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @city.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :country %><br />
20
+ <%= @country.name %>
21
+ </div>
22
+ <div class="actions">
23
+ <%= f.submit %>
24
+ </div>
25
+ <% 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,25 +1,29 @@
1
- <h1>Listing cities</h1>
2
-
3
- <table>
4
- <tr>
5
- <th>Name</th>
6
- <th>Country</th>
7
- <th></th>
8
- <th></th>
9
- <th></th>
10
- </tr>
11
-
12
- <% @cities.each do |city| %>
13
- <tr>
14
- <td><%= city.name %></td>
15
- <td><%= city.country.name %></td>
16
- <td><%= link_to 'Show', [@country, city] %></td>
17
- <td><%= link_to 'Edit', edit_country_city_path(@country, city) %></td>
18
- <td><%= link_to 'Destroy', [@country, city], method: :delete, data: { confirm: 'Are you sure?' } %></td>
19
- </tr>
20
- <% end %>
21
- </table>
22
-
23
- <br />
24
-
25
- <%= link_to 'New City', new_country_city_path(@country) %>
1
+ <h1>Listing cities</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Country</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ <th></th>
11
+ </tr>
12
+
13
+ <% @cities.each do |city| %>
14
+ <tr>
15
+ <td><%= city.name %></td>
16
+ <td><%= city.country.name %></td>
17
+ <td><%= link_to 'Show', [@country, city] %></td>
18
+ <td><%= link_to 'Edit', edit_country_city_path(@country, city) %></td>
19
+ <td><%= link_to 'Destroy', [@country, city], method: :delete, data: { confirm: 'Are you sure?' } %></td>
20
+ <td><%= link_to 'Streets', country_city_streets_path(@country, city) %></td>
21
+ </tr>
22
+ <% end %>
23
+ </table>
24
+
25
+ <br />
26
+
27
+ <%= link_to 'New City', new_country_city_path(@country) %>
28
+ <br>
29
+ <%= link_to 'Back to Countries', countries_path %>
@@ -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) %>
@@ -1,21 +1,21 @@
1
- <%= form_for(@country) do |f| %>
2
- <% if @country.errors.any? %>
3
- <div id="error_explanation">
4
- <h2><%= pluralize(@country.errors.count, "error") %> prohibited this country from being saved:</h2>
5
-
6
- <ul>
7
- <% @country.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <div class="field">
15
- <%= f.label :name %><br />
16
- <%= f.text_field :name %>
17
- </div>
18
- <div class="actions">
19
- <%= f.submit %>
20
- </div>
21
- <% end %>
1
+ <%= form_for(@country) do |f| %>
2
+ <% if @country.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@country.errors.count, "error") %> prohibited this country from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @country.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="actions">
19
+ <%= f.submit %>
20
+ </div>
21
+ <% end %>
@@ -1,6 +1,6 @@
1
- <h1>Editing country</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Show', @country %> |
6
- <%= link_to 'Back', countries_path %>
1
+ <h1>Editing country</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @country %> |
6
+ <%= link_to 'Back', countries_path %>
@@ -1,23 +1,25 @@
1
- <h1>Listing countries</h1>
2
-
3
- <table>
4
- <tr>
5
- <th>Name</th>
6
- <th></th>
7
- <th></th>
8
- <th></th>
9
- </tr>
10
-
11
- <% @countries.each do |country| %>
12
- <tr>
13
- <td><%= country.name %></td>
14
- <td><%= link_to 'Show', country %></td>
15
- <td><%= link_to 'Edit', edit_country_path(country) %></td>
16
- <td><%= link_to 'Destroy', country, method: :delete, data: { confirm: 'Are you sure?' } %></td>
17
- </tr>
18
- <% end %>
19
- </table>
20
-
21
- <br />
22
-
23
- <%= link_to 'New Country', new_country_path %>
1
+ <h1>Listing countries</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th></th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @countries.each do |country| %>
13
+ <tr>
14
+ <td><%= country.name %></td>
15
+ <td><%= link_to 'Show', country %></td>
16
+ <td><%= link_to 'Edit', edit_country_path(country) %></td>
17
+ <td><%= link_to 'Destroy', country, method: :delete, data: { confirm: 'Are you sure?' } %></td>
18
+ <td><%= link_to 'Cities', country_cities_path(country) %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'New Country', new_country_path %>
@@ -1,5 +1,5 @@
1
- <h1>New country</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Back', countries_path %>
1
+ <h1>New country</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', countries_path %>
@@ -1,10 +1,10 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <p>
4
- <b>Name:</b>
5
- <%= @country.name %>
6
- </p>
7
-
8
-
9
- <%= link_to 'Edit', edit_country_path(@country) %> |
10
- <%= link_to 'Back', countries_path %>
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @country.name %>
6
+ </p>
7
+
8
+
9
+ <%= link_to 'Edit', edit_country_path(@country) %> |
10
+ <%= link_to 'Back', countries_path %>
@@ -0,0 +1,21 @@
1
+ <%= form_for(@language) do |f| %>
2
+ <% if @language.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@language.errors.count, "error") %> prohibited this language from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @language.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="actions">
19
+ <%= f.submit %>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing language</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @language %> |
6
+ <%= link_to 'Back', languages_path %>
@@ -0,0 +1,23 @@
1
+ <h1>Listing languages</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th></th>
7
+ <th></th>
8
+ <th></th>
9
+ </tr>
10
+
11
+ <% @languages.each do |language| %>
12
+ <tr>
13
+ <td><%= language.name %></td>
14
+ <td><%= link_to 'Show', language %></td>
15
+ <td><%= link_to 'Edit', edit_language_path(language) %></td>
16
+ <td><%= link_to 'Destroy', language, method: :delete, data: { confirm: 'Are you sure?' } %></td>
17
+ </tr>
18
+ <% end %>
19
+ </table>
20
+
21
+ <br />
22
+
23
+ <%= link_to 'New Country', new_language_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New language</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', languages_path %>
@@ -0,0 +1,10 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @language.name %>
6
+ </p>
7
+
8
+
9
+ <%= link_to 'Edit', edit_language_path(@language) %> |
10
+ <%= link_to 'Back', languages_path %>
@@ -1,14 +1,14 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", :media => "all" %>
6
- <%= javascript_include_tag "application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,25 @@
1
+ <%= form_for([@country, @city, @street]) do |f| %>
2
+ <% if @street.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@street.errors.count, "error") %> prohibited this street from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @street.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :city %><br />
20
+ <%= @city.name %>
21
+ </div>
22
+ <div class="actions">
23
+ <%= f.submit %>
24
+ </div>
25
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing street</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', [@country, @city, @street] %> |
6
+ <%= link_to 'Back', country_city_streets_path(@country, @city) %>
@@ -0,0 +1,27 @@
1
+ <h1>Listing streets</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>City</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @streets.each do |street| %>
13
+ <tr>
14
+ <td><%= street.name %></td>
15
+ <td><%= street.city.name %></td>
16
+ <td><%= link_to 'Show', [@country, @city, street] %></td>
17
+ <td><%= link_to 'Edit', edit_country_city_street_path(@country, @city, street) %></td>
18
+ <td><%= link_to 'Destroy', [@country, @city, street], method: :delete, data: { confirm: 'Are you sure?' } %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'New Street', new_country_city_street_path(@country, @city) %>
26
+ <br>
27
+ <%= link_to 'Back to Cities', country_cities_path(@country) %>
@@ -0,0 +1,5 @@
1
+ <h1>New street</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', country_city_streets_path(@country, @city) %>
@@ -0,0 +1,15 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @street.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>City:</b>
10
+ <%= @street.city.name %>
11
+ </p>
12
+
13
+
14
+ <%= link_to 'Edit', edit_country_city_street_path(@country, @city, @street) %> |
15
+ <%= link_to 'Back', country_city_streets_path(@country, @city) %>