view_mapper 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -1
- data/VERSION +1 -1
- data/lib/view_mapper.rb +1 -0
- data/lib/view_mapper/belongs_to_parent_models.rb +12 -26
- data/lib/view_mapper/has_many_child_models.rb +9 -9
- data/lib/view_mapper/model_info.rb +56 -18
- data/lib/view_mapper/views/belongs_to/belongs_to_view.rb +14 -0
- data/lib/view_mapper/views/belongs_to_auto_complete/belongs_to_auto_complete_view.rb +9 -2
- data/lib/view_mapper/views/has_many/templates/helper.rb +1 -1
- data/lib/view_mapper/views/has_many/templates/view_child_form.html.erb +1 -1
- data/lib/view_mapper/views/has_many/templates/view_form.html.erb +1 -1
- data/lib/view_mapper/views/has_many_existing/has_many_existing_view.rb +126 -0
- data/lib/view_mapper/views/has_many_existing/templates/model.rb +21 -0
- data/lib/view_mapper/views/has_many_existing/templates/view_child_form.html.erb +16 -0
- data/lib/view_mapper/views/has_many_existing/templates/view_form.html.erb +20 -0
- data/lib/view_mapper/views/has_many_existing/templates/view_show.html.erb +26 -0
- data/test/generators/scaffold_for_view/scaffold_for_view_generator_test.rb +15 -15
- data/test/generators/view_for/view_for_generator_test.rb +18 -18
- data/test/model_info_test.rb +91 -20
- data/test/test_helper.rb +75 -105
- data/test/views/auto_complete/auto_complete_test.rb +104 -102
- data/test/views/auto_complete/expected_templates/edit.html.erb +6 -6
- data/test/views/auto_complete/expected_templates/expected_routes.rb +1 -1
- data/test/views/auto_complete/expected_templates/index.html.erb +10 -10
- data/test/views/auto_complete/expected_templates/new.html.erb +5 -5
- data/test/views/auto_complete/expected_templates/show.html.erb +6 -6
- data/test/views/auto_complete/expected_templates/{testies.html.erb → test_models.html.erb} +1 -1
- data/test/views/auto_complete/expected_templates/test_models_controller.rb +89 -0
- data/test/views/belongs_to/belongs_to_test.rb +238 -202
- data/test/views/belongs_to/expected_templates/_form.html.erb +4 -4
- data/test/views/belongs_to/expected_templates/child_model.rb +10 -0
- data/test/views/belongs_to/expected_templates/create_child_models.rb +18 -0
- data/test/views/belongs_to/expected_templates/edit.html.erb +4 -4
- data/test/views/belongs_to/expected_templates/index.html.erb +11 -11
- data/test/views/belongs_to/expected_templates/new.html.erb +3 -3
- data/test/views/belongs_to/expected_templates/show.html.erb +7 -7
- data/test/views/belongs_to_auto_complete/belongs_to_auto_complete_test.rb +440 -406
- data/test/views/belongs_to_auto_complete/expected_templates/_form.html.erb +4 -4
- data/test/views/belongs_to_auto_complete/expected_templates/child_model.rb +16 -0
- data/test/views/belongs_to_auto_complete/expected_templates/{some_other_models.html.erb → child_models.html.erb} +1 -1
- data/test/views/belongs_to_auto_complete/expected_templates/child_models_controller.rb +89 -0
- data/test/views/belongs_to_auto_complete/expected_templates/create_child_models.rb +18 -0
- data/test/views/belongs_to_auto_complete/expected_templates/edit.html.erb +4 -4
- data/test/views/belongs_to_auto_complete/expected_templates/expected_routes.rb +2 -2
- data/test/views/belongs_to_auto_complete/expected_templates/index.html.erb +11 -11
- data/test/views/belongs_to_auto_complete/expected_templates/new.html.erb +3 -3
- data/test/views/belongs_to_auto_complete/expected_templates/show.html.erb +7 -7
- data/test/views/has_many/expected_templates/_form.html.erb +8 -8
- data/test/views/has_many/expected_templates/{_person.html.erb → _second_child_model.html.erb} +5 -5
- data/test/views/has_many/expected_templates/create_parent_models.rb +16 -0
- data/test/views/has_many/expected_templates/edit.html.erb +4 -4
- data/test/views/has_many/expected_templates/index.html.erb +7 -7
- data/test/views/has_many/expected_templates/new.html.erb +3 -3
- data/test/views/has_many/expected_templates/{parent.rb → parent_model.rb} +5 -5
- data/test/views/has_many/expected_templates/show.html.erb +15 -15
- data/test/views/has_many/has_many_view_test.rb +334 -292
- data/test/views/has_many_existing/expected_templates/_assignment.html.erb +14 -0
- data/test/views/has_many_existing/expected_templates/_form.html.erb +16 -0
- data/test/views/{has_many/expected_templates/create_parents.rb → has_many_existing/expected_templates/create_programmers.rb} +3 -3
- data/test/views/has_many_existing/expected_templates/edit.html.erb +11 -0
- data/test/views/has_many_existing/expected_templates/index.html.erb +20 -0
- data/test/views/has_many_existing/expected_templates/new.html.erb +10 -0
- data/test/views/has_many_existing/expected_templates/programmer.rb +10 -0
- data/test/views/has_many_existing/expected_templates/show.html.erb +20 -0
- data/test/views/has_many_existing/has_many_existing_test.rb +495 -0
- data/test/views/paperclip/expected_templates/{create_testies.rb → create_test_models.rb} +3 -3
- data/test/views/paperclip/expected_templates/edit.html.erb +4 -4
- data/test/views/paperclip/expected_templates/index.html.erb +10 -10
- data/test/views/paperclip/expected_templates/new.html.erb +3 -3
- data/test/views/paperclip/expected_templates/show.html.erb +8 -8
- data/test/views/paperclip/expected_templates/{testy.rb → test_model.rb} +1 -1
- data/test/views/paperclip/paperclip_view_test.rb +254 -226
- data/view_mapper.gemspec +43 -27
- metadata +64 -37
- data/test/views/auto_complete/expected_templates/actual_index +0 -26
- data/test/views/auto_complete/expected_templates/testies_controller.rb +0 -89
- data/test/views/belongs_to/expected_templates/create_some_other_models.rb +0 -18
- data/test/views/belongs_to/expected_templates/some_other_model.rb +0 -10
- data/test/views/belongs_to_auto_complete/expected_templates/create_some_other_models.rb +0 -18
- data/test/views/belongs_to_auto_complete/expected_templates/some_other_model.rb +0 -16
- data/test/views/belongs_to_auto_complete/expected_templates/some_other_models_controller.rb +0 -89
@@ -4,10 +4,10 @@
|
|
4
4
|
<%= f.text_field :name %>
|
5
5
|
</p>
|
6
6
|
<p>
|
7
|
-
Parent:<br />
|
8
|
-
<%= text_field_with_auto_complete :
|
7
|
+
Parent Model:<br />
|
8
|
+
<%= text_field_with_auto_complete :child_model, :parent_model_name, {}, { :method => :get, :url => '/auto_complete_for_parent_model_name', :param_name => 'parent_model[name]' } %>
|
9
9
|
</p>
|
10
10
|
<p>
|
11
|
-
Second Parent:<br />
|
12
|
-
<%= text_field_with_auto_complete :
|
11
|
+
Second Parent Model:<br />
|
12
|
+
<%= text_field_with_auto_complete :child_model, :second_parent_model_other_field, {}, { :method => :get, :url => '/auto_complete_for_second_parent_model_other_field', :param_name => 'second_parent_model[other_field]' } %>
|
13
13
|
</p>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class ChildModel < ActiveRecord::Base
|
2
|
+
belongs_to :parent_model
|
3
|
+
belongs_to :second_parent_model
|
4
|
+
def parent_model_name
|
5
|
+
parent_model.name if parent_model
|
6
|
+
end
|
7
|
+
def parent_model_name=(name)
|
8
|
+
self.parent_model = ParentModel.find_by_name(name)
|
9
|
+
end
|
10
|
+
def second_parent_model_other_field
|
11
|
+
second_parent_model.other_field if second_parent_model
|
12
|
+
end
|
13
|
+
def second_parent_model_other_field=(other_field)
|
14
|
+
self.second_parent_model = SecondParentModel.find_by_other_field(other_field)
|
15
|
+
end
|
16
|
+
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
5
|
<head>
|
6
6
|
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
7
|
-
<title>
|
7
|
+
<title>ChildModels: <%= controller.action_name %></title>
|
8
8
|
<%= stylesheet_link_tag 'scaffold' %>
|
9
9
|
<%= javascript_include_tag :defaults %>
|
10
10
|
</head>
|
@@ -0,0 +1,89 @@
|
|
1
|
+
class ChildModelsController < ApplicationController
|
2
|
+
|
3
|
+
auto_complete_for :parent_model, :name
|
4
|
+
auto_complete_for :second_parent_model, :other_field
|
5
|
+
|
6
|
+
# GET /child_models
|
7
|
+
# GET /child_models.xml
|
8
|
+
def index
|
9
|
+
@child_models = ChildModel.all
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
format.html # index.html.erb
|
13
|
+
format.xml { render :xml => @child_models }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# GET /child_models/1
|
18
|
+
# GET /child_models/1.xml
|
19
|
+
def show
|
20
|
+
@child_model = ChildModel.find(params[:id])
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
format.html # show.html.erb
|
24
|
+
format.xml { render :xml => @child_model }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# GET /child_models/new
|
29
|
+
# GET /child_models/new.xml
|
30
|
+
def new
|
31
|
+
@child_model = ChildModel.new
|
32
|
+
|
33
|
+
respond_to do |format|
|
34
|
+
format.html # new.html.erb
|
35
|
+
format.xml { render :xml => @child_model }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# GET /child_models/1/edit
|
40
|
+
def edit
|
41
|
+
@child_model = ChildModel.find(params[:id])
|
42
|
+
end
|
43
|
+
|
44
|
+
# POST /child_models
|
45
|
+
# POST /child_models.xml
|
46
|
+
def create
|
47
|
+
@child_model = ChildModel.new(params[:child_model])
|
48
|
+
|
49
|
+
respond_to do |format|
|
50
|
+
if @child_model.save
|
51
|
+
flash[:notice] = 'ChildModel was successfully created.'
|
52
|
+
format.html { redirect_to(@child_model) }
|
53
|
+
format.xml { render :xml => @child_model, :status => :created, :location => @child_model }
|
54
|
+
else
|
55
|
+
format.html { render :action => "new" }
|
56
|
+
format.xml { render :xml => @child_model.errors, :status => :unprocessable_entity }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# PUT /child_models/1
|
62
|
+
# PUT /child_models/1.xml
|
63
|
+
def update
|
64
|
+
@child_model = ChildModel.find(params[:id])
|
65
|
+
|
66
|
+
respond_to do |format|
|
67
|
+
if @child_model.update_attributes(params[:child_model])
|
68
|
+
flash[:notice] = 'ChildModel was successfully updated.'
|
69
|
+
format.html { redirect_to(@child_model) }
|
70
|
+
format.xml { head :ok }
|
71
|
+
else
|
72
|
+
format.html { render :action => "edit" }
|
73
|
+
format.xml { render :xml => @child_model.errors, :status => :unprocessable_entity }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# DELETE /child_models/1
|
79
|
+
# DELETE /child_models/1.xml
|
80
|
+
def destroy
|
81
|
+
@child_model = ChildModel.find(params[:id])
|
82
|
+
@child_model.destroy
|
83
|
+
|
84
|
+
respond_to do |format|
|
85
|
+
format.html { redirect_to(child_models_url) }
|
86
|
+
format.xml { head :ok }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateChildModels < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :child_models do |t|
|
4
|
+
t.string :first_name
|
5
|
+
t.string :last_name
|
6
|
+
t.string :address
|
7
|
+
t.boolean :some_flag
|
8
|
+
t.integer :parent_model_id
|
9
|
+
t.integer :second_parent_model_id
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table :child_models
|
17
|
+
end
|
18
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<h1>Editing
|
1
|
+
<h1>Editing child_model</h1>
|
2
2
|
|
3
|
-
<% form_for(@
|
3
|
+
<% form_for(@child_model) do |f| %>
|
4
4
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
5
5
|
<p>
|
6
6
|
<%= f.submit 'Update' %>
|
7
7
|
</p>
|
8
8
|
<% end %>
|
9
9
|
|
10
|
-
<%= link_to 'Show', @
|
11
|
-
<%= link_to 'Back',
|
10
|
+
<%= link_to 'Show', @child_model %> |
|
11
|
+
<%= link_to 'Back', child_models_path %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
ActionController::Routing::Routes.draw do |map|
|
2
|
-
map.connect '
|
2
|
+
map.connect 'auto_complete_for_parent_model_name', :controller => 'child_models', :action => 'auto_complete_for_parent_model_name'
|
3
3
|
|
4
|
-
map.connect '
|
4
|
+
map.connect 'auto_complete_for_second_parent_model_other_field', :controller => 'child_models', :action => 'auto_complete_for_second_parent_model_other_field'
|
5
5
|
|
6
6
|
# The priority is based upon order of creation: first created -> highest priority.
|
7
7
|
|
@@ -1,24 +1,24 @@
|
|
1
|
-
<h1>Listing
|
1
|
+
<h1>Listing child_models</h1>
|
2
2
|
|
3
3
|
<table>
|
4
4
|
<tr>
|
5
5
|
<th>Name</th>
|
6
|
-
<th>Parent</th>
|
7
|
-
<th>Second Parent</th>
|
6
|
+
<th>Parent Model</th>
|
7
|
+
<th>Second Parent Model</th>
|
8
8
|
</tr>
|
9
9
|
|
10
|
-
<% @
|
10
|
+
<% @child_models.each do |child_model| %>
|
11
11
|
<tr>
|
12
|
-
<td><%=h
|
13
|
-
<td><%=h
|
14
|
-
<td><%=h
|
15
|
-
<td><%= link_to 'Show',
|
16
|
-
<td><%= link_to 'Edit',
|
17
|
-
<td><%= link_to 'Destroy',
|
12
|
+
<td><%=h child_model.name %></td>
|
13
|
+
<td><%=h child_model.parent_model_name %></td>
|
14
|
+
<td><%=h child_model.second_parent_model_other_field %></td>
|
15
|
+
<td><%= link_to 'Show', child_model %></td>
|
16
|
+
<td><%= link_to 'Edit', edit_child_model_path(child_model) %></td>
|
17
|
+
<td><%= link_to 'Destroy', child_model, :confirm => 'Are you sure?', :method => :delete %></td>
|
18
18
|
</tr>
|
19
19
|
<% end %>
|
20
20
|
</table>
|
21
21
|
|
22
22
|
<br />
|
23
23
|
|
24
|
-
<%= link_to 'New
|
24
|
+
<%= link_to 'New child_model', new_child_model_path %>
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<h1>New
|
1
|
+
<h1>New child_model</h1>
|
2
2
|
|
3
|
-
<% form_for(@
|
3
|
+
<% form_for(@child_model) do |f| %>
|
4
4
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
5
5
|
<p>
|
6
6
|
<%= f.submit 'Create' %>
|
7
7
|
</p>
|
8
8
|
<% end %>
|
9
9
|
|
10
|
-
<%= link_to 'Back',
|
10
|
+
<%= link_to 'Back', child_models_path %>
|
@@ -1,17 +1,17 @@
|
|
1
1
|
<p>
|
2
2
|
<b>Name:</b>
|
3
|
-
<%=h @
|
3
|
+
<%=h @child_model.name %>
|
4
4
|
</p>
|
5
5
|
|
6
6
|
<p>
|
7
|
-
<b>Parent:</b>
|
8
|
-
<%=h @
|
7
|
+
<b>Parent Model:</b>
|
8
|
+
<%=h @child_model.parent_model_name %>
|
9
9
|
</p>
|
10
10
|
|
11
11
|
<p>
|
12
|
-
<b>Second Parent:</b>
|
13
|
-
<%=h @
|
12
|
+
<b>Second Parent Model:</b>
|
13
|
+
<%=h @child_model.second_parent_model_other_field %>
|
14
14
|
</p>
|
15
15
|
|
16
|
-
<%= link_to 'Edit',
|
17
|
-
<%= link_to 'Back',
|
16
|
+
<%= link_to 'Edit', edit_child_model_path(@child_model) %> |
|
17
|
+
<%= link_to 'Back', child_models_path %>
|
@@ -5,22 +5,22 @@
|
|
5
5
|
<%= f.text_field :name %>
|
6
6
|
</p>
|
7
7
|
|
8
|
-
<div id='
|
9
|
-
<% f.fields_for :
|
10
|
-
<%= render :partial => '
|
8
|
+
<div id='child_model_children'>
|
9
|
+
<% f.fields_for :child_models do |child_model_form| %>
|
10
|
+
<%= render :partial => 'child_model', :locals => { :f => child_model_form } %>
|
11
11
|
<% end %>
|
12
12
|
</div>
|
13
13
|
|
14
14
|
<p>
|
15
|
-
<%= add_child_link 'Add
|
15
|
+
<%= add_child_link 'Add ChildModel', 'child_model', f %>
|
16
16
|
</p>
|
17
17
|
|
18
|
-
<div id='
|
19
|
-
<% f.fields_for :
|
20
|
-
<%= render :partial => '
|
18
|
+
<div id='second_child_model_children'>
|
19
|
+
<% f.fields_for :second_child_models do |second_child_model_form| %>
|
20
|
+
<%= render :partial => 'second_child_model', :locals => { :f => second_child_model_form } %>
|
21
21
|
<% end %>
|
22
22
|
</div>
|
23
23
|
|
24
24
|
<p>
|
25
|
-
<%= add_child_link 'Add
|
25
|
+
<%= add_child_link 'Add SecondChildModel', 'second_child_model', f %>
|
26
26
|
</p>
|
data/test/views/has_many/expected_templates/{_person.html.erb → _second_child_model.html.erb}
RENAMED
@@ -1,22 +1,22 @@
|
|
1
1
|
<div class="child">
|
2
2
|
<p>
|
3
|
-
|
3
|
+
SecondChildModel <%= f.label :first_name %><br />
|
4
4
|
<%= f.text_field :first_name %>
|
5
5
|
</p>
|
6
6
|
<p>
|
7
|
-
|
7
|
+
SecondChildModel <%= f.label :last_name %><br />
|
8
8
|
<%= f.text_field :last_name %>
|
9
9
|
</p>
|
10
10
|
<p>
|
11
|
-
|
11
|
+
SecondChildModel <%= f.label :address %><br />
|
12
12
|
<%= f.text_field :address %>
|
13
13
|
</p>
|
14
14
|
<p>
|
15
|
-
|
15
|
+
SecondChildModel <%= f.label :some_flag %><br />
|
16
16
|
<%= f.check_box :some_flag %>
|
17
17
|
</p>
|
18
18
|
<p>
|
19
|
-
<%= f.hidden_field :
|
19
|
+
<%= f.hidden_field :_destroy, :class => 'delete' %>
|
20
20
|
<%= remove_child_link 'remove', f %>
|
21
21
|
</p>
|
22
22
|
</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateParentModels < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :parent_models do |t|
|
4
|
+
t.string :first_name
|
5
|
+
t.string :last_name
|
6
|
+
t.string :address
|
7
|
+
t.boolean :some_flag
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :parent_models
|
15
|
+
end
|
16
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<h1>Editing
|
1
|
+
<h1>Editing parent_model</h1>
|
2
2
|
|
3
|
-
<% form_for(@
|
3
|
+
<% form_for(@parent_model) do |f| %>
|
4
4
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
5
5
|
<p>
|
6
6
|
<%= f.submit 'Update' %>
|
7
7
|
</p>
|
8
8
|
<% end %>
|
9
9
|
|
10
|
-
<%= link_to 'Show', @
|
11
|
-
<%= link_to 'Back',
|
10
|
+
<%= link_to 'Show', @parent_model %> |
|
11
|
+
<%= link_to 'Back', parent_models_path %>
|
@@ -1,20 +1,20 @@
|
|
1
|
-
<h1>Listing
|
1
|
+
<h1>Listing parent_models</h1>
|
2
2
|
|
3
3
|
<table>
|
4
4
|
<tr>
|
5
5
|
<th>Name</th>
|
6
6
|
</tr>
|
7
7
|
|
8
|
-
<% @
|
8
|
+
<% @parent_models.each do |parent_model| %>
|
9
9
|
<tr>
|
10
|
-
<td><%=h
|
11
|
-
<td><%= link_to 'Show',
|
12
|
-
<td><%= link_to 'Edit',
|
13
|
-
<td><%= link_to 'Destroy',
|
10
|
+
<td><%=h parent_model.name %></td>
|
11
|
+
<td><%= link_to 'Show', parent_model %></td>
|
12
|
+
<td><%= link_to 'Edit', edit_parent_model_path(parent_model) %></td>
|
13
|
+
<td><%= link_to 'Destroy', parent_model, :confirm => 'Are you sure?', :method => :delete %></td>
|
14
14
|
</tr>
|
15
15
|
<% end %>
|
16
16
|
</table>
|
17
17
|
|
18
18
|
<br />
|
19
19
|
|
20
|
-
<%= link_to 'New
|
20
|
+
<%= link_to 'New parent_model', new_parent_model_path %>
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<h1>New
|
1
|
+
<h1>New parent_model</h1>
|
2
2
|
|
3
|
-
<% form_for(@
|
3
|
+
<% form_for(@parent_model) do |f| %>
|
4
4
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
5
5
|
<p>
|
6
6
|
<%= f.submit 'Create' %>
|
7
7
|
</p>
|
8
8
|
<% end %>
|
9
9
|
|
10
|
-
<%= link_to 'Back',
|
10
|
+
<%= link_to 'Back', parent_models_path %>
|
@@ -1,10 +1,10 @@
|
|
1
|
-
class
|
2
|
-
has_many :
|
3
|
-
has_many :
|
4
|
-
accepts_nested_attributes_for :
|
1
|
+
class ParentModel < ActiveRecord::Base
|
2
|
+
has_many :child_models
|
3
|
+
has_many :second_child_models
|
4
|
+
accepts_nested_attributes_for :child_models,
|
5
5
|
:allow_destroy => true,
|
6
6
|
:reject_if => proc { |attrs| attrs['name'].blank? }
|
7
|
-
accepts_nested_attributes_for :
|
7
|
+
accepts_nested_attributes_for :second_child_models,
|
8
8
|
:allow_destroy => true,
|
9
9
|
:reject_if => proc { |attrs|
|
10
10
|
attrs['first_name'].blank? &&
|
@@ -1,37 +1,37 @@
|
|
1
1
|
<p>
|
2
2
|
<b>Name:</b>
|
3
|
-
<%=h @
|
3
|
+
<%=h @parent_model.name %>
|
4
4
|
</p>
|
5
5
|
|
6
|
-
<% @
|
6
|
+
<% @parent_model.child_models.each do |child_model| %>
|
7
7
|
<div class="child">
|
8
8
|
<p>
|
9
|
-
<b>
|
10
|
-
<%=h
|
9
|
+
<b>ChildModel Name:</b>
|
10
|
+
<%=h child_model.name %>
|
11
11
|
</p>
|
12
12
|
</div>
|
13
13
|
<% end %>
|
14
14
|
|
15
|
-
<% @
|
15
|
+
<% @parent_model.second_child_models.each do |second_child_model| %>
|
16
16
|
<div class="child">
|
17
17
|
<p>
|
18
|
-
<b>
|
19
|
-
<%=h
|
18
|
+
<b>SecondChildModel First name:</b>
|
19
|
+
<%=h second_child_model.first_name %>
|
20
20
|
</p>
|
21
21
|
<p>
|
22
|
-
<b>
|
23
|
-
<%=h
|
22
|
+
<b>SecondChildModel Last name:</b>
|
23
|
+
<%=h second_child_model.last_name %>
|
24
24
|
</p>
|
25
25
|
<p>
|
26
|
-
<b>
|
27
|
-
<%=h
|
26
|
+
<b>SecondChildModel Address:</b>
|
27
|
+
<%=h second_child_model.address %>
|
28
28
|
</p>
|
29
29
|
<p>
|
30
|
-
<b>
|
31
|
-
<%=h
|
30
|
+
<b>SecondChildModel Some flag:</b>
|
31
|
+
<%=h second_child_model.some_flag %>
|
32
32
|
</p>
|
33
33
|
</div>
|
34
34
|
<% end %>
|
35
35
|
|
36
|
-
<%= link_to 'Edit',
|
37
|
-
<%= link_to 'Back',
|
36
|
+
<%= link_to 'Edit', edit_parent_model_path(@parent_model) %> |
|
37
|
+
<%= link_to 'Back', parent_models_path %>
|