foldscaf 0.0.7 → 0.0.8
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.
- data/lib/generators/fold/fold_generator.rb +2 -1
- data/lib/generators/fold/templates/admin_controller.erb +57 -0
- data/lib/generators/fold/templates/cargar.erb +2 -1
- data/lib/generators/fold/templates/controller.erb +3 -55
- data/lib/generators/fold/templates/migration.erb +1 -0
- data/lib/generators/fold/templates/model.erb +1 -0
- data/lib/generators/fold/templates/views/nombre.erb +1 -1
- data/lib/version.rb +1 -1
- metadata +4 -3
@@ -40,7 +40,8 @@ class FoldGenerator < Rails::Generators::Base
|
|
40
40
|
def body
|
41
41
|
template 'model.erb' , "app/models/#{@singular}.rb"
|
42
42
|
template 'migration.erb' , "db/migrate/#{fecha}_create_#{@plural}.rb"
|
43
|
-
template 'controller.erb', "app/controllers
|
43
|
+
template 'controller.erb', "app/controllers/#{@plural}_controller.rb"
|
44
|
+
template 'admin_controller.erb', "app/controllers/admin/#{@plural}_controller.rb"
|
44
45
|
|
45
46
|
%w[_form _mini_form edit index new].each do |action|
|
46
47
|
template "views/#{action}.erb", "app/views/admin/#{@plural}/#{action}.html.erb"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Admin::<%= @classes %>Controller < Admin::AdminController
|
3
|
+
load_and_authorize_resource
|
4
|
+
<%- if @con_orden -%>
|
5
|
+
include Sortable
|
6
|
+
<%- end -%>
|
7
|
+
|
8
|
+
def index
|
9
|
+
@<%= @singular %> = <%= @class %>.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@<%= @singular %> = <%= @class %>.new params[:<%= @singular %>]
|
17
|
+
@<%= @singular %>.save!
|
18
|
+
notice = mensaje
|
19
|
+
|
20
|
+
respond_to do |format|
|
21
|
+
format.html { redirect_to <%= @plural_path %>, notice: notice }
|
22
|
+
format.js { @elemento = @<%= @singular %> }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def edit
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
@<%= @singular %>.update_attributes! params[:<%= @singular %>]
|
31
|
+
redirect_to <%= @edit_path %>(@<%= @singular %>), notice: mensaje
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy
|
35
|
+
@id = @<%= @singular %>.id
|
36
|
+
@<%= @singular %>.eliminar!
|
37
|
+
notice = mensaje
|
38
|
+
|
39
|
+
respond_to do |format|
|
40
|
+
format.html { redirect_to <%= @plural_path %>, notice: notice }
|
41
|
+
format.js
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def mensaje
|
48
|
+
flash.now.notice = t("notice.#{action_name}")
|
49
|
+
end
|
50
|
+
<%- if @con_orden -%>
|
51
|
+
|
52
|
+
def sort_coleccion
|
53
|
+
<%= @class %>.all
|
54
|
+
end
|
55
|
+
<%- end -%>
|
56
|
+
|
57
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
<%- atributos = @atributos.select {|x| x.ejemplo }.collect {|a| ":#{a.nombre} => #{a.ejemplo}" } -%>
|
2
3
|
namespace :cargar do
|
3
4
|
task :<%= @plural %> => :environment do
|
@@ -5,4 +6,4 @@ namespace :cargar do
|
|
5
6
|
<%= @class %>.create! <%= atributos.join(', ') %>
|
6
7
|
<%- end -%>
|
7
8
|
end
|
8
|
-
end
|
9
|
+
end
|
@@ -1,56 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
include Sortable
|
5
|
-
<%- end -%>
|
6
|
-
|
7
|
-
def index
|
8
|
-
@<%= @singular %> = <%= @class %>.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def new
|
12
|
-
end
|
13
|
-
|
14
|
-
def create
|
15
|
-
@<%= @singular %> = <%= @class %>.new params[:<%= @singular %>]
|
16
|
-
@<%= @singular %>.save!
|
17
|
-
notice = mensaje
|
18
|
-
|
19
|
-
respond_to do |format|
|
20
|
-
format.html { redirect_to <%= @plural_path %>, notice: notice }
|
21
|
-
format.js { @elemento = @<%= @singular %> }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def edit
|
26
|
-
end
|
27
|
-
|
28
|
-
def update
|
29
|
-
@<%= @singular %>.update_attributes! params[:<%= @singular %>]
|
30
|
-
redirect_to <%= @edit_path %>(@<%= @singular %>), notice: mensaje
|
31
|
-
end
|
32
|
-
|
33
|
-
def destroy
|
34
|
-
@id = @<%= @singular %>.id
|
35
|
-
@<%= @singular %>.eliminar!
|
36
|
-
notice = mensaje
|
37
|
-
|
38
|
-
respond_to do |format|
|
39
|
-
format.html { redirect_to <%= @plural_path %>, notice: notice }
|
40
|
-
format.js
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def mensaje
|
47
|
-
flash.now.notice = t("notice.#{action_name}")
|
48
|
-
end
|
49
|
-
<%- if @con_orden -%>
|
50
|
-
|
51
|
-
def sort_coleccion
|
52
|
-
<%= @class %>.all
|
53
|
-
end
|
54
|
-
<%- end -%>
|
55
|
-
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class <%= @classes %>Controller < ApplicationController
|
3
|
+
|
56
4
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<%- if @con_orden -%>
|
5
5
|
<%%= link_to icono('move', :black) + " Mover", "#", :class => 'btn btn-mini handle', :title => 'Mantenga click y arrastre para reordenar' %>
|
6
6
|
<%- end -%>
|
7
|
-
<%%= link_to 'Editar', <%= @edit_path %>(<%= @singular %>), :class => 'btn btn-mini' if can? :
|
7
|
+
<%%= link_to 'Editar', <%= @edit_path %>(<%= @singular %>), :class => 'btn btn-mini' if can? :update, <%= @singular %> %>
|
8
8
|
<%%= link_to "Eliminar", <%= @singular_path %>(<%= @singular %>), :method => :delete, :confirm => t("confirmacion"), :remote => true, :class => 'btn btn-mini btn-danger' if can? :destroy, <%= @singular %> %>
|
9
9
|
</td>
|
10
10
|
<%% end %>
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foldscaf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-17 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Generadores adaptados a las necesidades de Xaver
|
15
15
|
email:
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- lib/generators/fold/USAGE
|
29
29
|
- lib/generators/fold/atributo.rb
|
30
30
|
- lib/generators/fold/fold_generator.rb
|
31
|
+
- lib/generators/fold/templates/admin_controller.erb
|
31
32
|
- lib/generators/fold/templates/cargar.erb
|
32
33
|
- lib/generators/fold/templates/controller.erb
|
33
34
|
- lib/generators/fold/templates/migration.erb
|
@@ -62,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
63
|
version: '0'
|
63
64
|
requirements: []
|
64
65
|
rubyforge_project: foldscaf
|
65
|
-
rubygems_version: 1.8.
|
66
|
+
rubygems_version: 1.8.10
|
66
67
|
signing_key:
|
67
68
|
specification_version: 3
|
68
69
|
summary: Generadores adaptados a las necesidades de Xaver
|