ava_scaffold_generator 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/ava_scaffold_generator.rb +7 -0
- data/templates/controller.rb +8 -4
- data/templates/view_check.html.erb +6 -3
- data/templates/view_confirm.html.erb +6 -3
- data/templates/view_edit.html.erb +2 -2
- data/templates/view_index.html.erb +2 -2
- data/templates/view_new.html.erb +2 -2
- data/templates/view_show.html.erb +7 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/ava_scaffold_generator.rb
CHANGED
@@ -33,6 +33,13 @@ class AvaScaffoldGenerator < Rails::Generator::NamedBase
|
|
33
33
|
else
|
34
34
|
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
|
35
35
|
end
|
36
|
+
|
37
|
+
# attributes.each_with_index{|attribute, i|
|
38
|
+
# def attribute.title
|
39
|
+
# title = @args[i].split(":")[2]
|
40
|
+
# end
|
41
|
+
# }
|
42
|
+
|
36
43
|
end
|
37
44
|
|
38
45
|
def manifest
|
data/templates/controller.rb
CHANGED
@@ -4,11 +4,13 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
4
4
|
def index
|
5
5
|
@app_search.default 'id', 'desc'
|
6
6
|
|
7
|
+
@app_search.sort 'id', '<%= plural_name %>.id'
|
7
8
|
<% conditions_l = "" -%>
|
8
9
|
<% conditions_r = "" -%>
|
9
10
|
<% for attribute in attributes -%>
|
10
|
-
|
11
|
-
|
11
|
+
<% reference_col = attribute.reference? ? "_id" : "" -%>
|
12
|
+
@app_search.sort '<%= attribute.name %>', '<%= plural_name %>.<%= attribute.name %><%= reference_col %>'
|
13
|
+
<% conditions_l += "#{plural_name}.#{attribute.name}#{reference_col} like ? or " -%>
|
12
14
|
<% conditions_r += '@app_search.keyword, ' -%>
|
13
15
|
<% end -%>
|
14
16
|
<% conditions_l = conditions_l.slice(0, conditions_l.size - 3) -%>
|
@@ -27,7 +29,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
27
29
|
|
28
30
|
respond_to do |format|
|
29
31
|
format.html # index.html.erb
|
30
|
-
format.csv { send_data(xmls.to_csv(<%= class_name %>), :type => "text/csv") }
|
32
|
+
format.csv { send_data(xmls.to_csv(:instance => <%= class_name %>), :type => "text/csv") }
|
31
33
|
# format.xml { send_data(xmls.to_xml, :type => "text/xml; charset=utf8;", :disposition => "attachement") }
|
32
34
|
end
|
33
35
|
end
|
@@ -39,7 +41,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
39
41
|
|
40
42
|
respond_to do |format|
|
41
43
|
format.html # show.html.erb
|
42
|
-
format.csv { send_data(@<%= file_name %>.to_a.to_csv, :type => "text/csv") }
|
44
|
+
format.csv { send_data(@<%= file_name %>.to_a.to_csv(:instance => <%= class_name %>), :type => "text/csv") }
|
43
45
|
# format.xml { send_data(@<%= file_name %>.to_xml, :type => "text/xml; charset=utf8;", :disposition => "attachement") }
|
44
46
|
end
|
45
47
|
end
|
@@ -109,6 +111,8 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
109
111
|
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
110
112
|
@<%= file_name %>.destroy
|
111
113
|
|
114
|
+
Log.create(:user_id => session_get_user, :action => controller_name, :error => action_name + " " + params[:id])
|
115
|
+
|
112
116
|
flash[:notice] = t(:success_deleted, :id => @<%= file_name %>.id)
|
113
117
|
redirect_to(<%= file_name %>s_url)
|
114
118
|
rescue => e
|
@@ -33,16 +33,19 @@
|
|
33
33
|
<tr>
|
34
34
|
<th><%%= f.label :<%= attribute.name %> %></th>
|
35
35
|
<td>
|
36
|
-
<% if
|
37
|
-
<%%= hname @<%= singular_name %>.<%= attribute.name
|
36
|
+
<% if attribute.reference? -%>
|
37
|
+
<%%= hname @<%= singular_name %>.<%= attribute.name %> %>
|
38
|
+
<%%= f.hidden_field :<%= attribute.name %>_id %>
|
38
39
|
<% elsif attribute.field_type == :date_select -%>
|
39
40
|
<%%= hdate @<%= singular_name %>.<%= attribute.name %> %>
|
41
|
+
<%%= f.hidden_field :<%= attribute.name %> %>
|
40
42
|
<% elsif attribute.field_type == :text_area -%>
|
41
43
|
<%%= hbr @<%= singular_name %>.<%= attribute.name %> %>
|
44
|
+
<%%= f.hidden_field :<%= attribute.name %> %>
|
42
45
|
<% else -%>
|
43
46
|
<%%= h @<%= singular_name %>.<%= attribute.name %> %>
|
44
|
-
<% end -%>
|
45
47
|
<%%= f.hidden_field :<%= attribute.name %> %>
|
48
|
+
<% end -%>
|
46
49
|
</td>
|
47
50
|
</tr>
|
48
51
|
<% end -%>
|
@@ -33,16 +33,19 @@
|
|
33
33
|
<tr>
|
34
34
|
<th><%%= f.label :<%= attribute.name %> %></th>
|
35
35
|
<td>
|
36
|
-
<% if
|
37
|
-
<%%= hname @<%= singular_name %>.<%= attribute.name
|
36
|
+
<% if attribute.reference? -%>
|
37
|
+
<%%= hname @<%= singular_name %>.<%= attribute.name %> %>
|
38
|
+
<%%= f.hidden_field :<%= attribute.name %>_id %>
|
38
39
|
<% elsif attribute.field_type == :date_select -%>
|
39
40
|
<%%= hdate @<%= singular_name %>.<%= attribute.name %> %>
|
41
|
+
<%%= f.hidden_field :<%= attribute.name %> %>
|
40
42
|
<% elsif attribute.field_type == :text_area -%>
|
41
43
|
<%%= hbr @<%= singular_name %>.<%= attribute.name %> %>
|
44
|
+
<%%= f.hidden_field :<%= attribute.name %> %>
|
42
45
|
<% else -%>
|
43
46
|
<%%= h @<%= singular_name %>.<%= attribute.name %> %>
|
44
|
-
<% end -%>
|
45
47
|
<%%= f.hidden_field :<%= attribute.name %> %>
|
48
|
+
<% end -%>
|
46
49
|
</td>
|
47
50
|
</tr>
|
48
51
|
<% end -%>
|
@@ -34,8 +34,8 @@
|
|
34
34
|
<tr>
|
35
35
|
<th><%%= f.label :<%= attribute.name %> %></th>
|
36
36
|
<td>
|
37
|
-
<% if
|
38
|
-
<%%= f.collection_select(:<%= attribute.name
|
37
|
+
<% if attribute.reference? -%>
|
38
|
+
<%%= f.collection_select(:<%= attribute.name %>_id, <%= attribute.name.capitalize %>.find(:all), :id, :name, :include_blank => true) %>
|
39
39
|
<% elsif attribute.field_type == :text_area -%>
|
40
40
|
<%%= f.text_area :<%= attribute.name %>, :size => "60x5" %>
|
41
41
|
<% elsif attribute.field_type == :check_box -%>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
<!--/ commonBtnArea--></div>
|
23
23
|
|
24
24
|
<div class="list">
|
25
|
-
<%%=
|
25
|
+
<%%= paginate_tag @<%= plural_name %> %>
|
26
26
|
<%%= counter_tag %>
|
27
27
|
<table class="commonList">
|
28
28
|
<thead>
|
@@ -38,7 +38,7 @@
|
|
38
38
|
<tr>
|
39
39
|
<td><%%=link_to <%= singular_name %>.id, <%= singular_name %> %></td>
|
40
40
|
<% for attribute in attributes -%>
|
41
|
-
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
41
|
+
<td><%%=h<%= attribute.reference? ? "name": "" %> <%= singular_name %>.<%= attribute.name %> %></td>
|
42
42
|
<% end -%>
|
43
43
|
</tr>
|
44
44
|
<%% end %>
|
data/templates/view_new.html.erb
CHANGED
@@ -34,8 +34,8 @@
|
|
34
34
|
<tr>
|
35
35
|
<th><%%= f.label :<%= attribute.name %> %></th>
|
36
36
|
<td>
|
37
|
-
<% if
|
38
|
-
<%%= f.collection_select(:<%= attribute.name
|
37
|
+
<% if attribute.reference? -%>
|
38
|
+
<%%= f.collection_select(:<%= attribute.name %>_id, <%= attribute.name.capitalize %>.find(:all), :id, :name, :include_blank => true) %>
|
39
39
|
<% elsif attribute.field_type == :text_area -%>
|
40
40
|
<%%= f.text_area :<%= attribute.name %>, :size => "60x5" %>
|
41
41
|
<% elsif attribute.field_type == :check_box -%>
|
@@ -39,14 +39,19 @@
|
|
39
39
|
<tr>
|
40
40
|
<th><%%= f.label :<%= attribute.name %> %></th>
|
41
41
|
<td>
|
42
|
-
<% if attribute.
|
42
|
+
<% if attribute.reference? -%>
|
43
|
+
<%%= hname @<%= singular_name %>.<%= attribute.name %> %>
|
44
|
+
<%%= f.hidden_field :<%= attribute.name %>_id %>
|
45
|
+
<% elsif attribute.field_type == :date_select -%>
|
43
46
|
<%%= hdate @<%= singular_name %>.<%= attribute.name %> %>
|
47
|
+
<%%= f.hidden_field :<%= attribute.name %> %>
|
44
48
|
<% elsif attribute.field_type == :text_area -%>
|
45
49
|
<%%= hbr @<%= singular_name %>.<%= attribute.name %> %>
|
50
|
+
<%%= f.hidden_field :<%= attribute.name %> %>
|
46
51
|
<% else -%>
|
47
52
|
<%%= h @<%= singular_name %>.<%= attribute.name %> %>
|
48
|
-
<% end -%>
|
49
53
|
<%%= f.hidden_field :<%= attribute.name %> %>
|
54
|
+
<% end -%>
|
50
55
|
</td>
|
51
56
|
</tr>
|
52
57
|
<% end -%>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ava_scaffold_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Masaki Ozawa
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-04-
|
18
|
+
date: 2012-04-12 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|