r5 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/r5/installations/default.rb +1 -1
- data/lib/r5/template/config/initializers/html_helpers.rb +1 -1
- data/lib/r5/template/lib/templates/active_record/migration/create_table_migration.rb +27 -0
- data/lib/r5/template/lib/templates/active_record/model/model.rb +14 -0
- data/lib/r5/template/lib/templates/erb/scaffold/edit.html.erb +1 -1
- data/lib/r5/template/lib/templates/migration/templates/create_table_migration.rb +25 -0
- data/lib/r5/template/lib/templates/rails/scaffold_controller/controller.rb +3 -3
- data/lib/r5/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a1eaf3b57459810152098f4af02c91499677633
|
4
|
+
data.tar.gz: 420c8330dd7cddb7f8fb1187ae896c7697bb3e9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82dec5da99cc35906e5cc1f5f70db0df95e1a539c5654e34b2cd748d36145febda6b3ae91f992a3ee01d35200dfb1d8caa0126da3f92d8f4d80ae7e5da2c5a24
|
7
|
+
data.tar.gz: 79d2c6f06e50542d2a08d48bc77a6cc32f36f287e0d1e63c7682f0980f873a4a264dbedc5249454f2ffd5ac08c09d57739f35f23591876656c00f157b7066876
|
@@ -40,7 +40,7 @@ layout_file = "#{@project_path}/app/views/layouts/application.html.erb"
|
|
40
40
|
remove 'app/views/layouts/application.html.erb'
|
41
41
|
copy 'app/views/layouts/application.html.erb'
|
42
42
|
apply 'recipes/mail_settings.rb'
|
43
|
-
apply 'recipes/
|
43
|
+
apply 'recipes/timepress_specifics.rb'
|
44
44
|
gsub_file layout_file, 'PROJECT_NAME', @project_name
|
45
45
|
apply 'recipes/gitignore.rb'
|
46
46
|
run 'git init'
|
@@ -86,7 +86,7 @@ module ApplicationHelper
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def delete_button objekt, text
|
89
|
-
link_to '
|
89
|
+
link_to 'Archive', objekt, method: :delete, data: { confirm: text }, class: 'btn btn-danger pull-right' if params[:action] == 'edit'
|
90
90
|
end
|
91
91
|
|
92
92
|
def session_debug
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# this one should working just fine, but there is bug in Rails so I need to put template to lib/templates/migration/templates/create_table_migration.rb
|
2
|
+
# https://github.com/rails/rails/pull/13972
|
3
|
+
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
4
|
+
def change
|
5
|
+
create_table :<%= table_name %><%= primary_key_type %> do |t|
|
6
|
+
<% attributes.each do |attribute| -%>
|
7
|
+
<% if attribute.password_digest? -%>
|
8
|
+
t.string :password_digest<%= attribute.inject_options %>
|
9
|
+
<% elsif attribute.token? -%>
|
10
|
+
t.string :<%= attribute.name %><%= attribute.inject_options %>
|
11
|
+
<% else -%>
|
12
|
+
t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
|
13
|
+
<% end -%>
|
14
|
+
<% end -%>
|
15
|
+
<% if options[:timestamps] %>
|
16
|
+
t.timestamps
|
17
|
+
<% end -%>
|
18
|
+
t.datetime :archived_at
|
19
|
+
end
|
20
|
+
<% attributes.select(&:token?).each do |attribute| -%>
|
21
|
+
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>, unique: true
|
22
|
+
<% end -%>
|
23
|
+
<% attributes_with_index.each do |attribute| -%>
|
24
|
+
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
|
25
|
+
<% end -%>
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% module_namespacing do -%>
|
2
|
+
class <%= class_name %> < <%= parent_class_name.classify %>
|
3
|
+
<% attributes.select(&:reference?).each do |attribute| -%>
|
4
|
+
belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %><%= ', required: true' if attribute.required? %>
|
5
|
+
<% end -%>
|
6
|
+
scope :active, -> { where(archived_at: nil) }
|
7
|
+
<% attributes.select(&:token?).each do |attribute| -%>
|
8
|
+
has_secure_token<% if attribute.name != "token" %> :<%= attribute.name %><% end %>
|
9
|
+
<% end -%>
|
10
|
+
<% if attributes.any?(&:password_digest?) -%>
|
11
|
+
has_secure_password
|
12
|
+
<% end -%>
|
13
|
+
end
|
14
|
+
<% end -%>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div class="page-header">
|
2
|
-
<%%= delete_button @<%= singular_table_name %>, 'Do you really want to
|
2
|
+
<%%= delete_button @<%= singular_table_name %>, 'Do you really want to archive <%= singular_table_name %>?' %>
|
3
3
|
<h1>Editing <%= singular_table_name %></h1>
|
4
4
|
</div>
|
5
5
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
2
|
+
def change
|
3
|
+
create_table :<%= table_name %><%= primary_key_type %> do |t|
|
4
|
+
<% attributes.each do |attribute| -%>
|
5
|
+
<% if attribute.password_digest? -%>
|
6
|
+
t.string :password_digest<%= attribute.inject_options %>
|
7
|
+
<% elsif attribute.token? -%>
|
8
|
+
t.string :<%= attribute.name %><%= attribute.inject_options %>
|
9
|
+
<% else -%>
|
10
|
+
t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
|
11
|
+
<% end -%>
|
12
|
+
<% end -%>
|
13
|
+
<% if options[:timestamps] %>
|
14
|
+
t.timestamps
|
15
|
+
<% end -%>
|
16
|
+
t.datetime :archived_at
|
17
|
+
end
|
18
|
+
<% attributes.select(&:token?).each do |attribute| -%>
|
19
|
+
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>, unique: true
|
20
|
+
<% end -%>
|
21
|
+
<% attributes_with_index.each do |attribute| -%>
|
22
|
+
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
|
23
|
+
<% end -%>
|
24
|
+
end
|
25
|
+
end
|
@@ -6,7 +6,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
6
6
|
before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
|
7
7
|
# GET <%= route_url %>
|
8
8
|
def index
|
9
|
-
@<%= plural_table_name %> = <%=
|
9
|
+
@<%= plural_table_name %> = <%= class_name %>.active
|
10
10
|
end
|
11
11
|
# GET <%= route_url %>/1
|
12
12
|
def show
|
@@ -41,8 +41,8 @@ if @<%= orm_instance.save %>
|
|
41
41
|
end
|
42
42
|
# DELETE <%= route_url %>/1
|
43
43
|
def destroy
|
44
|
-
@<%= orm_instance.
|
45
|
-
redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully
|
44
|
+
@<%= orm_instance.update("archived_at: Time.now") %>
|
45
|
+
redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully archived.'" %>
|
46
46
|
end
|
47
47
|
private
|
48
48
|
# Use callbacks to share common setup or constraints between actions.
|
data/lib/r5/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r5
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mousse
|
@@ -114,11 +114,14 @@ files:
|
|
114
114
|
- lib/r5/template/config/locales/cs.yml
|
115
115
|
- lib/r5/template/lib/tasks/bootstrap.rake
|
116
116
|
- lib/r5/template/lib/tasks/upload.rake
|
117
|
+
- lib/r5/template/lib/templates/active_record/migration/create_table_migration.rb
|
118
|
+
- lib/r5/template/lib/templates/active_record/model/model.rb
|
117
119
|
- lib/r5/template/lib/templates/erb/scaffold/_form.html.erb
|
118
120
|
- lib/r5/template/lib/templates/erb/scaffold/edit.html.erb
|
119
121
|
- lib/r5/template/lib/templates/erb/scaffold/index.html.erb
|
120
122
|
- lib/r5/template/lib/templates/erb/scaffold/new.html.erb
|
121
123
|
- lib/r5/template/lib/templates/erb/scaffold/show.html.erb
|
124
|
+
- lib/r5/template/lib/templates/migration/templates/create_table_migration.rb
|
122
125
|
- lib/r5/template/lib/templates/rails/scaffold_controller/controller.rb
|
123
126
|
- lib/r5/version.rb
|
124
127
|
- r5.gemspec
|