nu-generators 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -1
- data/lib/generators/nu/scaffold_generator.rb +1 -1
- data/lib/generators/nu/templates/scaffold/controller.rb +18 -9
- data/lib/generators/nu/templates/scaffold/views/all.html.erb +24 -20
- data/lib/generators/nu/templates/scaffold/views/edit.html.erb +4 -3
- data/lib/generators/nu/templates/scaffold/views/index.html.erb +21 -0
- data/lib/generators/nu/templates/scaffold/views/new.html.erb +2 -1
- data/lib/nu-generators/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
# nu generators
|
2
2
|
|
3
|
-
|
3
|
+
Personalized generator for scaffolds.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
group :development do
|
11
|
+
gem 'nu-generators', '~> 0.0.2'
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
4
18
|
|
5
19
|
## usage:
|
6
20
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class <%= class_name.pluralize %>Controller < ApplicationController
|
2
|
-
#before_filter :authenticate_user!, except: [:show]
|
2
|
+
#before_filter :authenticate_user!, except: [:index, :show]
|
3
3
|
|
4
|
-
def
|
4
|
+
def index
|
5
5
|
@<%= plural_table_name %> = <%= class_name.singularize %>.all
|
6
6
|
|
7
7
|
respond_to do |format|
|
@@ -9,15 +9,24 @@ class <%= class_name.pluralize %>Controller < ApplicationController
|
|
9
9
|
format.json { render json: @<%= plural_table_name %> }
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def show
|
14
|
-
@<%= singular_table_name %> = <%= class_name.singularize %>.
|
14
|
+
@<%= singular_table_name %> = <%= class_name.singularize %>.find(params[:id])
|
15
15
|
|
16
16
|
respond_to do |format|
|
17
17
|
format.html # show.html.erb
|
18
18
|
format.json { render json: @<%= singular_table_name %> }
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
def all
|
23
|
+
@<%= plural_table_name %> = <%= class_name.singularize %>.all
|
24
|
+
|
25
|
+
respond_to do |format|
|
26
|
+
format.html # all.html.erb
|
27
|
+
format.json { render json: @<%= plural_table_name %> }
|
28
|
+
end
|
29
|
+
end
|
21
30
|
|
22
31
|
def new
|
23
32
|
@<%= singular_table_name %> = <%= class_name.singularize %>.new
|
@@ -29,7 +38,7 @@ class <%= class_name.pluralize %>Controller < ApplicationController
|
|
29
38
|
end
|
30
39
|
|
31
40
|
def edit
|
32
|
-
@<%= singular_table_name %> = <%= class_name.singularize %>.
|
41
|
+
@<%= singular_table_name %> = <%= class_name.singularize %>.find(params[:id])
|
33
42
|
end
|
34
43
|
|
35
44
|
def create
|
@@ -37,7 +46,7 @@ class <%= class_name.pluralize %>Controller < ApplicationController
|
|
37
46
|
|
38
47
|
respond_to do |format|
|
39
48
|
if @<%= singular_table_name %>.save
|
40
|
-
format.html { redirect_to edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) }
|
49
|
+
format.html { redirect_to edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), <%= key_value :notice, "'#{human_name} was successfully created.'" %> }
|
41
50
|
format.json { render json: @<%= singular_table_name %>, status: :created, location: @<%= singular_table_name %> }
|
42
51
|
else
|
43
52
|
format.html { render "new" }
|
@@ -47,11 +56,11 @@ class <%= class_name.pluralize %>Controller < ApplicationController
|
|
47
56
|
end
|
48
57
|
|
49
58
|
def update
|
50
|
-
@<%= singular_table_name %> = <%= class_name.singularize %>.
|
59
|
+
@<%= singular_table_name %> = <%= class_name.singularize %>.find(params[:id])
|
51
60
|
|
52
61
|
respond_to do |format|
|
53
62
|
if @<%= singular_table_name %>.update_attributes(params[:<%= singular_table_name %>])
|
54
|
-
format.html { redirect_to all_<%= plural_table_name %>_path }
|
63
|
+
format.html { redirect_to all_<%= plural_table_name %>_path, <%= key_value :notice, "'#{human_name} was successfully updated.'" %> }
|
55
64
|
format.json { head :ok }
|
56
65
|
else
|
57
66
|
format.html { render "edit" }
|
@@ -61,7 +70,7 @@ class <%= class_name.pluralize %>Controller < ApplicationController
|
|
61
70
|
end
|
62
71
|
|
63
72
|
def destroy
|
64
|
-
@<%= singular_table_name %> = <%= class_name.singularize %>.
|
73
|
+
@<%= singular_table_name %> = <%= class_name.singularize %>.find(params[:id])
|
65
74
|
@<%= singular_table_name %>.destroy
|
66
75
|
|
67
76
|
respond_to do |format|
|
@@ -1,27 +1,31 @@
|
|
1
|
-
<
|
1
|
+
<div class="publisher">
|
2
|
+
<h1><%%= t("publisher.listing") %> <%%= t("menu.<%= plural_table_name %>") %></h1>
|
3
|
+
<%%= link_to "+ #{t('publisher.new')}", new_<%= singular_table_name %>_path, <%= key_value :class, "'btn btn-primary'" %> %>
|
2
4
|
|
3
|
-
<table>
|
4
|
-
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
5
8
|
<% attributes.each do |attribute| -%>
|
6
|
-
|
9
|
+
<th><%= attribute.human_name %></th>
|
7
10
|
<% end -%>
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
</tr>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
</thead>
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
<tbody>
|
16
|
+
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
17
|
+
<tr class="#cycle('odd', 'even')">
|
15
18
|
<% attributes.each do |attribute| -%>
|
16
|
-
|
19
|
+
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
|
17
20
|
<% end -%>
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
<td>
|
22
|
+
<%%= link_to t('publisher.edit'), edit_<%= singular_table_name %>_path(<%= singular_table_name %>), <%= key_value :class, "'btn btn-mini btn-danger'" %> %>
|
23
|
+
<%%= link_to t('publisher.destroy'), <%= singular_table_name %>, <%= key_value :method, ":delete" %>, <%= key_value :data, "{ confirm: t('publisher.confirm') }" %>, <%= key_value :class, "'btn btn-mini btn-danger'" %> %></td>
|
24
|
+
</td>
|
25
|
+
</tr>
|
26
|
+
<%% end %>
|
27
|
+
</tbody>
|
28
|
+
</table>
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
<%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path %>
|
30
|
+
<%%= link_to "+ #{t('publisher.new')}", new_<%= singular_table_name %>_path, <%= key_value :class, "'btn btn-primary'" %> %>
|
31
|
+
</div>
|
@@ -1,5 +1,6 @@
|
|
1
|
-
<div class="publisher">
|
2
|
-
<h1
|
1
|
+
<div class="publisher">
|
2
|
+
<h1><%%= t("publisher.editing") %> <%%= t("menu.<%= singular_table_name %>") %>: <%%#= @<%= singular_table_name %>.name %></h1>
|
3
|
+
<%%= link_to "« #{t('publisher.list_all')}", all_<%= plural_table_name %>_path, <%= key_value :class, "'btn'" %> %>
|
3
4
|
|
4
|
-
<%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %>
|
5
|
+
<%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %>
|
5
6
|
</div>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<h1>Listing <%= plural_table_name %></h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<% attributes.each do |attribute| -%>
|
6
|
+
<th><%= attribute.human_name %></th>
|
7
|
+
<% end -%>
|
8
|
+
<th></th>
|
9
|
+
<th></th>
|
10
|
+
<th></th>
|
11
|
+
</tr>
|
12
|
+
|
13
|
+
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
14
|
+
<tr>
|
15
|
+
<% attributes.each do |attribute| -%>
|
16
|
+
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
|
17
|
+
<% end -%>
|
18
|
+
<td><%%= link_to 'Show', <%= singular_table_name %> %></td>
|
19
|
+
</tr>
|
20
|
+
<%% end %>
|
21
|
+
</table>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<div class="publisher">
|
2
|
-
<h1
|
2
|
+
<h1><%%= t("publisher.new") %> <%%= t("menu.<%= singular_table_name %>") %></h1>
|
3
|
+
<%%= link_to "« #{t('publisher.list_all')}", all_<%= plural_table_name %>_path, <%= key_value :class, "'btn'" %> %>
|
3
4
|
|
4
5
|
<%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %>
|
5
6
|
</div>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nu-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-12-23 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: nu design custom generators
|
17
17
|
email:
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- lib/generators/nu/templates/scaffold/views/_form.html.erb
|
38
38
|
- lib/generators/nu/templates/scaffold/views/all.html.erb
|
39
39
|
- lib/generators/nu/templates/scaffold/views/edit.html.erb
|
40
|
+
- lib/generators/nu/templates/scaffold/views/index.html.erb
|
40
41
|
- lib/generators/nu/templates/scaffold/views/new.html.erb
|
41
42
|
- lib/generators/nu/templates/scaffold/views/show.html.erb
|
42
43
|
- lib/nu-generators.rb
|