crud 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/crud/klass_info.rb +7 -1
- data/app/views/crud/crud/_form.html.erb +3 -1
- data/config/routes.rb +22 -9
- data/lib/crud/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c13137f3cd61c4548411788c62812424776b992b
|
4
|
+
data.tar.gz: 170567c4d0ae6a5a5f8a9c91634ab0be6a7e2c3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ce6de70b3b1ccf93869be5a7e8969a8d3dc4c049f9288c62a13c14638657f65c226dfc83993590599cae500e458287f7cf5e1cff799a1766cea1994cf2ac301
|
7
|
+
data.tar.gz: aa2ca0f928033540a88d1a639ce78b407cf2b4535827c9c63dcba36bce787acca965970d87e02b5482820cf29f147e074e95cb5f04e58c4c472aea56fb5ec930
|
@@ -22,6 +22,11 @@ module Crud
|
|
22
22
|
self[:attributes][i][:column_class_type] = self[:class].column_names[i].class
|
23
23
|
self[:attributes][i][:column_data_type] = self[:class].columns[i].type
|
24
24
|
|
25
|
+
validators_for_attribute = self[:class].validators_on(self[:attributes][i][:column_name].to_sym).map(&:class)
|
26
|
+
self[:attributes][i][:required] = (Rails.version.to_f < 4.0) ?
|
27
|
+
false :
|
28
|
+
(validators_for_attribute.include?(ActiveModel::Validations::PresenceValidator) || validators_for_attribute.include?(ActiveRecord::Validations::PresenceValidator))
|
29
|
+
|
25
30
|
# Initialise belongs_to associations
|
26
31
|
reflection_value = belongs_to_reflection_values.select {
|
27
32
|
|k| k.name == self[:attributes][i][:column_name].sub(/_id$/,'').to_sym
|
@@ -92,7 +97,8 @@ module Crud
|
|
92
97
|
if (row)
|
93
98
|
associated_attribute = associated_polymorphic_attribute(attribute)
|
94
99
|
if associated_attribute && associated_attribute.length == 1 && row.attributes[associated_attribute[0][:column_name]]
|
95
|
-
|
100
|
+
associated_class_name = row.attributes[associated_attribute[0][:column_name]]
|
101
|
+
associated_class = associated_class_name.empty? ? nil : associated_class_name.constantize
|
96
102
|
end
|
97
103
|
end
|
98
104
|
associated_class
|
@@ -5,7 +5,9 @@
|
|
5
5
|
<% @visible_attributes.each do |attribute| %>
|
6
6
|
<% unless ['id','created_at', 'updated_at'].include?(attribute[:column_name]) %>
|
7
7
|
<div class="field">
|
8
|
-
<%= f.label attribute[:column_name].to_sym
|
8
|
+
<%= f.label attribute[:column_name].to_sym %>
|
9
|
+
<%= '<span style="color: red;">*</span>'.html_safe if attribute[:required] -%>
|
10
|
+
<br />
|
9
11
|
<% custom_fields = @klass_info.custom_fields(attribute[:column_name], controller.action_name.to_sym) %>
|
10
12
|
<% custom_fields_contain_a_replacement = @klass_info.custom_fields_contain_a_replacement(custom_fields) %>
|
11
13
|
<% unless custom_fields_contain_a_replacement %>
|
data/config/routes.rb
CHANGED
@@ -1,14 +1,27 @@
|
|
1
1
|
Crud::Engine.routes.draw do
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
if (Rails.version.to_f < 4.0)
|
4
|
+
controller 'crud' do
|
5
|
+
match '/model/*class_name/new', :to => :new, :via => :get, :as => :new
|
6
|
+
match '/model/*class_name/:id/delete', :to => :delete, :via => :delete, :as => :delete
|
7
|
+
match '/model/*class_name/:id/edit', :to => :edit, :via => :get, :as => :edit
|
8
|
+
match '/model/*class_name/:id', :to => :show, :via => :get, :as => :show
|
9
|
+
match '/model/*class_name/:id', :to => :update, :via => :put, :as => :update
|
10
|
+
match '/model/*class_name/:id', :to => :destroy, :via => :delete, :as => :destroy
|
11
|
+
match '/model/(*class_name)', :to => :create, :via => :post, :as => :create
|
12
|
+
match '/model/(*class_name)', :to => :index, :via => :get, :as => :index
|
13
|
+
end
|
14
|
+
else
|
15
|
+
controller 'crud' do
|
16
|
+
match '/model/*class_name/new', :action => :new, :via => :get, :as => :new
|
17
|
+
match '/model/*class_name/:id/delete', :action => :delete, :via => :delete, :as => :delete
|
18
|
+
match '/model/*class_name/:id/edit', :action => :edit, :via => :get, :as => :edit
|
19
|
+
match '/model/*class_name/:id', :action => :show, :via => :get, :as => :show
|
20
|
+
match '/model/*class_name/:id', :action => :update, :via => :put, :as => :update
|
21
|
+
match '/model/*class_name/:id', :action => :destroy, :via => :delete, :as => :destroy
|
22
|
+
match '/model/(*class_name)', :action => :create, :via => :post, :as => :create
|
23
|
+
match '/model/(*class_name)', :action => :index, :via => :get, :as => :index
|
24
|
+
end
|
12
25
|
end
|
13
26
|
|
14
27
|
#get 'dashboard' => 'dashboard#index'
|
data/lib/crud/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Everard Brown
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -150,8 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
152
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.4.
|
153
|
+
rubygems_version: 2.4.7
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
|
-
summary: Crud engine (v0.0.
|
156
|
+
summary: Crud engine (v0.0.4)
|
157
157
|
test_files: []
|