caseadilla 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/Gemfile +0 -0
  4. data/LICENSE.txt +0 -0
  5. data/README.md +0 -0
  6. data/Rakefile +0 -0
  7. data/app/assets/fonts/caseadilla/glyphicons-halflings-regular.eot +0 -0
  8. data/app/assets/fonts/caseadilla/glyphicons-halflings-regular.svg +228 -228
  9. data/app/assets/fonts/caseadilla/glyphicons-halflings-regular.ttf +0 -0
  10. data/app/assets/fonts/caseadilla/glyphicons-halflings-regular.woff +0 -0
  11. data/app/assets/images/caseadilla/caseadilla.png +0 -0
  12. data/app/assets/javascripts/caseadilla/bootstrap.js +2114 -2114
  13. data/app/assets/javascripts/caseadilla/bootstrap3-wysihtml5.js +520 -520
  14. data/app/assets/javascripts/caseadilla/caseadilla.js +50 -50
  15. data/app/assets/javascripts/caseadilla/html5shiv.js +8 -8
  16. data/app/assets/javascripts/caseadilla/wysihtml5-0.3.0.min.js +260 -260
  17. data/app/assets/stylesheets/caseadilla/bootstrap-glyphicons.css.scss +2 -2
  18. data/app/assets/stylesheets/caseadilla/bootstrap-theme.css +442 -442
  19. data/app/assets/stylesheets/caseadilla/bootstrap-wysihtml5.css +101 -101
  20. data/app/assets/stylesheets/caseadilla/bootstrap.css +6203 -6203
  21. data/app/assets/stylesheets/caseadilla/caseadilla-bootstrap-overrides.css.scss +79 -79
  22. data/app/assets/stylesheets/caseadilla/caseadilla.scss +269 -269
  23. data/app/assets/stylesheets/caseadilla/login.css.scss +80 -80
  24. data/app/controllers/caseadilla/caseadilla_controller.rb +56 -56
  25. data/app/controllers/caseadilla/caseadilla_user_sessions_controller.rb +35 -35
  26. data/app/controllers/caseadilla/password_resets_controller.rb +63 -63
  27. data/app/controllers/caseadilla/roles_controller.rb +64 -64
  28. data/app/controllers/caseadilla/users_controller.rb +117 -117
  29. data/app/helpers/caseadilla/caseadilla_helper.rb +261 -261
  30. data/app/mailers/caseadilla/caseadilla_notification.rb +38 -38
  31. data/app/views/caseadilla/caseadilla/blank.html.erb +11 -11
  32. data/app/views/caseadilla/caseadilla_notification/generate_new_password.erb +11 -11
  33. data/app/views/caseadilla/caseadilla_notification/new_user_information.erb +11 -11
  34. data/app/views/caseadilla/caseadilla_notification/password_reset_instructions.erb +10 -10
  35. data/app/views/caseadilla/caseadilla_user_sessions/new.html.erb +38 -38
  36. data/app/views/caseadilla/roles/_form.html.erb +11 -11
  37. data/app/views/caseadilla/roles/_table.html.erb +27 -27
  38. data/app/views/caseadilla/roles/index.html.erb +14 -14
  39. data/app/views/caseadilla/roles/new.html.erb +17 -17
  40. data/app/views/caseadilla/roles/show.html.erb +17 -17
  41. data/app/views/caseadilla/users/index.html.erb +36 -36
  42. data/app/views/caseadilla/users/new.html.erb +49 -49
  43. data/app/views/caseadilla/users/show.html.erb +38 -38
  44. data/app/views/layouts/caseadilla_auth.html.erb +36 -36
  45. data/app/views/layouts/caseadilla_main.html.erb +110 -118
  46. data/caseadilla.gemspec +48 -48
  47. data/config/initializers/will_paginate.rb +39 -39
  48. data/config/routes.rb +22 -22
  49. data/lib/caseadilla.rb +13 -13
  50. data/lib/caseadilla/engine.rb +34 -34
  51. data/lib/caseadilla/version.rb +1 -1
  52. data/lib/generators/caseadilla/install/install_generator.rb +153 -153
  53. data/lib/generators/caseadilla/install/templates/app/assets/javascripts/caseadilla/custom.js +1 -1
  54. data/lib/generators/caseadilla/install/templates/app/assets/stylesheets/caseadilla/custom.css.scss +2 -2
  55. data/lib/generators/caseadilla/install/templates/app/helpers/caseadilla/config_helper.rb +44 -44
  56. data/lib/generators/caseadilla/install/templates/app/models/user.rb +23 -23
  57. data/lib/generators/caseadilla/install/templates/app/views/caseadilla/layouts/_tab_navigation.html.erb +1 -1
  58. data/lib/generators/caseadilla/install/templates/app/views/caseadilla/layouts/_top_navigation.html.erb +3 -3
  59. data/lib/generators/caseadilla/install/templates/public/robots.txt +4 -4
  60. data/lib/generators/caseadilla/install/templates/steak/config/initializers/caseadilla.rb +7 -7
  61. data/lib/generators/caseadilla/install/templates/steak/db/migrate/add_name_to_users.rb +8 -8
  62. data/lib/generators/caseadilla/install/templates/veggie/config/initializers/caseadilla.rb +7 -7
  63. data/lib/generators/caseadilla/scaffold/scaffold_generator.rb +110 -110
  64. data/lib/generators/caseadilla/scaffold/templates/controller.rb +71 -71
  65. data/lib/generators/caseadilla/scaffold/templates/migration.rb +12 -12
  66. data/lib/generators/caseadilla/scaffold/templates/model.rb +2 -2
  67. data/lib/generators/caseadilla/scaffold/templates/views/_form.html.erb +11 -11
  68. data/lib/generators/caseadilla/scaffold/templates/views/_table.html.erb +18 -18
  69. data/lib/generators/caseadilla/scaffold/templates/views/index.html.erb +14 -14
  70. data/lib/generators/caseadilla/scaffold/templates/views/new.html.erb +17 -17
  71. data/lib/generators/caseadilla/scaffold/templates/views/show.html.erb +17 -17
  72. data/lib/railties/tasks.rake +31 -31
  73. metadata +2 -2
@@ -1,2 +1,2 @@
1
- // CASEIN CUSTOM
1
+ // CASEIN CUSTOM
2
2
  // Use this file for your project-specific Caseadilla JavaScript
@@ -1,2 +1,2 @@
1
- /* CASEIN CUSTOM */
2
- /* Use this file for your project-specific Caseadilla CSS */
1
+ /* CASEIN CUSTOM */
2
+ /* Use this file for your project-specific Caseadilla CSS */
@@ -1,45 +1,45 @@
1
- module Caseadilla
2
- module ConfigHelper
3
-
4
- # Name of website or client — used throughout Caseadilla.
5
- def caseadilla_config_website_name
6
- 'Caseadilla'
7
- end
8
-
9
- # Filename of logo image. Ideally, it should be a transparent PNG around 140x30px
10
- def caseadilla_config_logo
11
- 'caseadilla/caseadilla.png'
12
- end
13
-
14
- # The server hostname where Caseadilla will run
15
- def caseadilla_config_hostname
16
- if Rails.env.production?
17
- 'http://www.caseadillacms.com'
18
- else
19
- 'http://0.0.0.0:3000'
20
- end
21
- end
22
-
23
- # The sender address used for email notifications
24
- def caseadilla_config_email_from_address
25
- 'donotreply@caseadillacms.com'
26
- end
27
-
28
- # The initial page the user is shown after they sign in or click the logo. Probably this should be set to the first tab.
29
- # Do not point this at caseadilla/index!
30
- def caseadilla_config_dashboard_url
31
- url_for :controller => :caseadilla, :action => :blank
32
- end
33
-
34
- # A list of stylesheets to include. Do not remove the core caseadilla/caseadilla, but you can change the load order, if required.
35
- def caseadilla_config_stylesheet_includes
36
- %w[caseadilla/caseadilla caseadilla/custom]
37
- end
38
-
39
- # A list of JavaScript files to include. Do not remove the core caseadilla/caseadilla, but you can change the load order, if required.
40
- def caseadilla_config_javascript_includes
41
- %w[caseadilla/caseadilla caseadilla/custom]
42
- end
43
-
44
- end
1
+ module Caseadilla
2
+ module ConfigHelper
3
+
4
+ # Name of website or client — used throughout Caseadilla.
5
+ def caseadilla_config_website_name
6
+ 'Caseadilla'
7
+ end
8
+
9
+ # Filename of logo image. Ideally, it should be a transparent PNG around 140x30px
10
+ def caseadilla_config_logo
11
+ 'caseadilla/caseadilla.png'
12
+ end
13
+
14
+ # The server hostname where Caseadilla will run
15
+ def caseadilla_config_hostname
16
+ if Rails.env.production?
17
+ 'http://www.caseadillacms.com'
18
+ else
19
+ 'http://0.0.0.0:3000'
20
+ end
21
+ end
22
+
23
+ # The sender address used for email notifications
24
+ def caseadilla_config_email_from_address
25
+ 'donotreply@caseadillacms.com'
26
+ end
27
+
28
+ # The initial page the user is shown after they sign in or click the logo. Probably this should be set to the first tab.
29
+ # Do not point this at caseadilla/index!
30
+ def caseadilla_config_dashboard_url
31
+ url_for :controller => :caseadilla, :action => :blank
32
+ end
33
+
34
+ # A list of stylesheets to include. Do not remove the core caseadilla/caseadilla, but you can change the load order, if required.
35
+ def caseadilla_config_stylesheet_includes
36
+ %w[caseadilla/caseadilla caseadilla/custom]
37
+ end
38
+
39
+ # A list of JavaScript files to include. Do not remove the core caseadilla/caseadilla, but you can change the load order, if required.
40
+ def caseadilla_config_javascript_includes
41
+ %w[caseadilla/caseadilla caseadilla/custom]
42
+ end
43
+
44
+ end
45
45
  end
@@ -1,24 +1,24 @@
1
- class User < ActiveRecord::Base
2
- belongs_to :role
3
- before_create :add_user_role
4
- # Include default devise modules. Others available are:
5
- # :confirmable, :lockable, :timeoutable and :omniauthable
6
- devise :database_authenticatable, :registerable,
7
- :recoverable, :rememberable, :trackable, :validatable
8
-
9
-
10
- def name
11
- "#{first_name} #{last_name}"
12
- end
13
-
14
- def role_symbols
15
- [role.title.to_sym]
16
- end
17
-
18
- private
19
-
20
- def add_user_role
21
- self.role = Role.find_by_title 'user'
22
- end
23
-
1
+ class User < ActiveRecord::Base
2
+ belongs_to :role
3
+ before_create :add_user_role
4
+ # Include default devise modules. Others available are:
5
+ # :confirmable, :lockable, :timeoutable and :omniauthable
6
+ devise :database_authenticatable, :registerable,
7
+ :recoverable, :rememberable, :trackable, :validatable
8
+
9
+
10
+ def name
11
+ "#{first_name} #{last_name}"
12
+ end
13
+
14
+ def role_symbols
15
+ [role.title.to_sym]
16
+ end
17
+
18
+ private
19
+
20
+ def add_user_role
21
+ self.role = Role.find_by_title 'user'
22
+ end
23
+
24
24
  end
@@ -1,2 +1,2 @@
1
- <!-- NOTE: the caseadilla:scaffold generator automatically appends new controllers to this file. The SCAFFOLD_INSERT line must NOT be removed -->
1
+ <!-- NOTE: the caseadilla:scaffold generator automatically appends new controllers to this file. The SCAFFOLD_INSERT line must NOT be removed -->
2
2
  <!-- SCAFFOLD_INSERT -->
@@ -1,4 +1,4 @@
1
- <!-- NOTE: add "hidden-sm" class to li elements you want to be hidden at small browser widths -->
2
- <!-- e.g. <li class="hidden-sm"><%= link_to "Visit site", caseadilla_config_hostname, :target => "_blank" %></li> -->
3
-
1
+ <!-- NOTE: add "hidden-sm" class to li elements you want to be hidden at small browser widths -->
2
+ <!-- e.g. <li class="hidden-sm"><%= link_to "Visit site", caseadilla_config_hostname, :target => "_blank" %></li> -->
3
+
4
4
  <li><%= link_to "Visit site", caseadilla_config_hostname, :target => "_blank" %></li>
@@ -1,5 +1,5 @@
1
- User-agent: *
2
- Disallow: /caseadilla
3
- Disallow: /admin
4
-
1
+ User-agent: *
2
+ Disallow: /caseadilla
3
+ Disallow: /admin
4
+
5
5
  Allow: /
@@ -1,8 +1,8 @@
1
- ######################################################
2
- ## Note: It is HIGHLY recommended that you use the
3
- ## the caseadilla installer to change the flavor by
4
- ## overwriting existing files. Example:
5
- ## $ rails g caseadilla:install veggie
6
- ######################################################
7
-
1
+ ######################################################
2
+ ## Note: It is HIGHLY recommended that you use the
3
+ ## the caseadilla installer to change the flavor by
4
+ ## overwriting existing files. Example:
5
+ ## $ rails g caseadilla:install veggie
6
+ ######################################################
7
+
8
8
  Caseadilla::Engine.flavor = :steak
@@ -1,9 +1,9 @@
1
- class AddNameToUsers < ActiveRecord::Migration
2
-
3
- def change
4
- add_column :users, :first_name, :string
5
- add_column :users, :last_name, :string
6
- add_column :users, :time_zone, :string
7
- end
8
-
1
+ class AddNameToUsers < ActiveRecord::Migration
2
+
3
+ def change
4
+ add_column :users, :first_name, :string
5
+ add_column :users, :last_name, :string
6
+ add_column :users, :time_zone, :string
7
+ end
8
+
9
9
  end
@@ -1,8 +1,8 @@
1
- ######################################################
2
- ## Note: It is HIGHLY recommended that you use the
3
- ## the caseadilla installer to change the flavor by
4
- ## overwriting existing files. Example:
5
- ## $ rails g caseadilla:install chicken
6
- ######################################################
7
-
1
+ ######################################################
2
+ ## Note: It is HIGHLY recommended that you use the
3
+ ## the caseadilla installer to change the flavor by
4
+ ## overwriting existing files. Example:
5
+ ## $ rails g caseadilla:install chicken
6
+ ######################################################
7
+
8
8
  Caseadilla::Engine.flavor = :veggie
@@ -1,111 +1,111 @@
1
- module Caseadilla
2
- class ScaffoldGenerator < Rails::Generators::NamedBase
3
-
4
- include Caseadilla::CaseadillaHelper
5
- include Rails::Generators::Migration
6
- source_root File.expand_path('../templates', __FILE__)
7
-
8
- argument :attributes, :type => :array, :required => true, :desc => "attribute list required"
9
-
10
- class_options :create_model => false, :read_only => false, :no_index => false
11
-
12
- def self.next_migration_number dirname
13
- if ActiveRecord::Base.timestamped_migrations
14
- Time.now.utc.strftime("%Y%m%d%H%M%S")
15
- else
16
- "%.3d" % (current_migration_number(dirname) + 1)
17
- end
18
- end
19
-
20
- def generate_files
21
- @plural_route = (plural_name != singular_name) ? plural_name : "#{plural_name}_index"
22
- @read_only = options[:read_only]
23
- @no_index = options[:no_index]
24
-
25
- template 'controller.rb', "app/controllers/caseadilla/#{plural_name}_controller.rb"
26
- template 'views/index.html.erb', "app/views/caseadilla/#{plural_name}/index.html.erb" unless @no_index
27
- template 'views/show.html.erb', "app/views/caseadilla/#{plural_name}/show.html.erb"
28
- template 'views/new.html.erb', "app/views/caseadilla/#{plural_name}/new.html.erb" unless @read_only
29
- template 'views/_form.html.erb', "app/views/caseadilla/#{plural_name}/_form.html.erb"
30
- template 'views/_table.html.erb', "app/views/caseadilla/#{plural_name}/_table.html.erb"
31
-
32
- add_namespace_to_routes
33
- add_to_routes
34
- add_to_navigation unless @no_index
35
-
36
- if options[:create_model]
37
- template 'model.rb', "app/models/#{singular_name}.rb"
38
- migration_template 'migration.rb', "db/migrate/create_#{plural_name}.rb"
39
- end
40
- end
41
-
42
- protected
43
-
44
- #replacements for standard Rails generator route. This one only adds once
45
- def add_namespace_to_routes
46
- puts " caseadilla adding namespace to routes.rb"
47
- file_to_update = Rails.root + 'config/routes.rb'
48
- line_to_add = "namespace :caseadilla do"
49
- insert_sentinel = 'Application.routes.draw do'
50
- if File.read(file_to_update).scan(/(#{Regexp.escape("#{line_to_add}")})/mi).blank?
51
- gsub_add_once plural_name, file_to_update, "\n\t#Caseadilla routes\n\t" + line_to_add + "\n\tend\n", insert_sentinel
52
- end
53
- end
54
-
55
- def add_to_routes
56
- puts " caseadilla adding #{plural_name} resources to routes.rb"
57
- file_to_update = Rails.root + 'config/routes.rb'
58
-
59
- if @no_index && @read_only
60
- line_to_add = "resources :#{plural_name}, :only => [:show]"
61
- elsif @no_index
62
- line_to_add = "resources :#{plural_name}, :except => [:index]"
63
- elsif @read_only
64
- line_to_add = "resources :#{plural_name}, :only => [:index, :show]"
65
- else
66
- line_to_add = "resources :#{plural_name}"
67
- end
68
-
69
- insert_sentinel = 'namespace :caseadilla do'
70
- gsub_add_once plural_name, file_to_update, "\t\t" + line_to_add, insert_sentinel
71
- end
72
-
73
- def add_to_navigation
74
- puts " caseadilla adding #{plural_name} to left navigation bar"
75
- file_to_update = Rails.root + 'app/views/caseadilla/layouts/_tab_navigation.html.erb'
76
- line_to_add = "<li id=\"tab-#{@plural_route}\"><%= link_to \"#{plural_name.humanize.capitalize}\", caseadilla_#{@plural_route}_path %></li>"
77
- insert_sentinel = '<!-- SCAFFOLD_INSERT -->'
78
- gsub_add_once plural_name, file_to_update, line_to_add, insert_sentinel
79
- end
80
-
81
- def gsub_add_once m, file, line, sentinel
82
- unless options[:pretend]
83
- gsub_file file, /(#{Regexp.escape("\n#{line}")})/mi do |match|
84
- ''
85
- end
86
- gsub_file file, /(#{Regexp.escape(sentinel)})/mi do |match|
87
- "#{match}\n#{line}"
88
- end
89
- end
90
- end
91
-
92
- def gsub_file(path, regexp, *args, &block)
93
- content = File.read(path).gsub(regexp, *args, &block)
94
- File.open(path, 'wb') { |file| file.write(content) }
95
- end
96
-
97
- def field_type(type)
98
- case type.to_s.to_sym
99
- when :integer, :float, :decimal then :text_field
100
- when :date then :date_select
101
- when :time, :timestamp then :time_select
102
- when :datetime then :datetime_select
103
- when :string then :text_field
104
- when :text then :text_area
105
- when :boolean then :check_box
106
- else
107
- :text_field
108
- end
109
- end
110
- end
1
+ module Caseadilla
2
+ class ScaffoldGenerator < Rails::Generators::NamedBase
3
+
4
+ include Caseadilla::CaseadillaHelper
5
+ include Rails::Generators::Migration
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ argument :attributes, :type => :array, :required => true, :desc => "attribute list required"
9
+
10
+ class_options :create_model => false, :read_only => false, :no_index => false
11
+
12
+ def self.next_migration_number dirname
13
+ if ActiveRecord::Base.timestamped_migrations
14
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
15
+ else
16
+ "%.3d" % (current_migration_number(dirname) + 1)
17
+ end
18
+ end
19
+
20
+ def generate_files
21
+ @plural_route = (plural_name != singular_name) ? plural_name : "#{plural_name}_index"
22
+ @read_only = options[:read_only]
23
+ @no_index = options[:no_index]
24
+
25
+ template 'controller.rb', "app/controllers/caseadilla/#{plural_name}_controller.rb"
26
+ template 'views/index.html.erb', "app/views/caseadilla/#{plural_name}/index.html.erb" unless @no_index
27
+ template 'views/show.html.erb', "app/views/caseadilla/#{plural_name}/show.html.erb"
28
+ template 'views/new.html.erb', "app/views/caseadilla/#{plural_name}/new.html.erb" unless @read_only
29
+ template 'views/_form.html.erb', "app/views/caseadilla/#{plural_name}/_form.html.erb"
30
+ template 'views/_table.html.erb', "app/views/caseadilla/#{plural_name}/_table.html.erb"
31
+
32
+ add_namespace_to_routes
33
+ add_to_routes
34
+ add_to_navigation unless @no_index
35
+
36
+ if options[:create_model]
37
+ template 'model.rb', "app/models/#{singular_name}.rb"
38
+ migration_template 'migration.rb', "db/migrate/create_#{plural_name}.rb"
39
+ end
40
+ end
41
+
42
+ protected
43
+
44
+ #replacements for standard Rails generator route. This one only adds once
45
+ def add_namespace_to_routes
46
+ puts " caseadilla adding namespace to routes.rb"
47
+ file_to_update = Rails.root + 'config/routes.rb'
48
+ line_to_add = "namespace :caseadilla do"
49
+ insert_sentinel = 'Application.routes.draw do'
50
+ if File.read(file_to_update).scan(/(#{Regexp.escape("#{line_to_add}")})/mi).blank?
51
+ gsub_add_once plural_name, file_to_update, "\n\t#Caseadilla routes\n\t" + line_to_add + "\n\tend\n", insert_sentinel
52
+ end
53
+ end
54
+
55
+ def add_to_routes
56
+ puts " caseadilla adding #{plural_name} resources to routes.rb"
57
+ file_to_update = Rails.root + 'config/routes.rb'
58
+
59
+ if @no_index && @read_only
60
+ line_to_add = "resources :#{plural_name}, :only => [:show]"
61
+ elsif @no_index
62
+ line_to_add = "resources :#{plural_name}, :except => [:index]"
63
+ elsif @read_only
64
+ line_to_add = "resources :#{plural_name}, :only => [:index, :show]"
65
+ else
66
+ line_to_add = "resources :#{plural_name}"
67
+ end
68
+
69
+ insert_sentinel = 'namespace :caseadilla do'
70
+ gsub_add_once plural_name, file_to_update, "\t\t" + line_to_add, insert_sentinel
71
+ end
72
+
73
+ def add_to_navigation
74
+ puts " caseadilla adding #{plural_name} to left navigation bar"
75
+ file_to_update = Rails.root + 'app/views/caseadilla/layouts/_tab_navigation.html.erb'
76
+ line_to_add = "<li id=\"tab-#{@plural_route}\"><%= link_to \"#{plural_name.humanize.capitalize}\", caseadilla_#{@plural_route}_path %></li>"
77
+ insert_sentinel = '<!-- SCAFFOLD_INSERT -->'
78
+ gsub_add_once plural_name, file_to_update, line_to_add, insert_sentinel
79
+ end
80
+
81
+ def gsub_add_once m, file, line, sentinel
82
+ unless options[:pretend]
83
+ gsub_file file, /(#{Regexp.escape("\n#{line}")})/mi do |match|
84
+ ''
85
+ end
86
+ gsub_file file, /(#{Regexp.escape(sentinel)})/mi do |match|
87
+ "#{match}\n#{line}"
88
+ end
89
+ end
90
+ end
91
+
92
+ def gsub_file(path, regexp, *args, &block)
93
+ content = File.read(path).gsub(regexp, *args, &block)
94
+ File.open(path, 'wb') { |file| file.write(content) }
95
+ end
96
+
97
+ def field_type(type)
98
+ case type.to_s.to_sym
99
+ when :integer, :float, :decimal then :text_field
100
+ when :date then :date_select
101
+ when :time, :timestamp then :time_select
102
+ when :datetime then :datetime_select
103
+ when :string then :text_field
104
+ when :text then :text_area
105
+ when :boolean then :check_box
106
+ else
107
+ :text_field
108
+ end
109
+ end
110
+ end
111
111
  end
@@ -1,72 +1,72 @@
1
- # Scaffolding generated by Caseadilla <%= caseadilla_get_full_version_string %>
2
-
3
- module Caseadilla
4
- class <%= class_name.pluralize %>Controller < Caseadilla::CaseadillaController
5
-
6
- ## optional filters for defining usage according to Caseadilla::AdminUser access_levels
7
- # before_filter :needs_admin, :except => [:action1, :action2]
8
- # before_filter :needs_admin_or_current_user, :only => [:action1, :action2]
9
- <% unless @no_index %>
10
- def index
11
- @caseadilla_page_title = '<%= plural_name.humanize.capitalize %>'
12
- @<%= plural_name %> = <%= class_name %>.order(sort_order(:<%= attributes[0].name %>)).paginate :page => params[:page]
13
- end
14
- <% end %>
15
- def show
16
- @caseadilla_page_title = 'View <%= singular_name.humanize.downcase %>'
17
- @<%= singular_name %> = <%= class_name %>.find params[:id]
18
- end
19
- <% unless @read_only %>
20
- def new
21
- @caseadilla_page_title = 'Add a new <%= singular_name.humanize.downcase %>'
22
- @<%= singular_name %> = <%= class_name %>.new
23
- end
24
-
25
- def create
26
- @<%= singular_name %> = <%= class_name %>.new <%= singular_name %>_params
27
-
28
- if @<%= singular_name %>.save
29
- flash[:notice] = '<%= singular_name.humanize.capitalize %> created'
30
- redirect_to caseadilla_<%= @plural_route %>_path
31
- else
32
- flash.now[:warning] = 'There were problems when trying to create a new <%= singular_name.humanize.downcase %>'
33
- render :action => :new
34
- end
35
- end
36
-
37
- def update
38
- @caseadilla_page_title = 'Update <%= singular_name.humanize.downcase %>'
39
-
40
- @<%= singular_name %> = <%= class_name %>.find params[:id]
41
-
42
- if @<%= singular_name %>.update_attributes <%= singular_name %>_params
43
- flash[:notice] = '<%= singular_name.humanize.capitalize %> has been updated'
44
- redirect_to caseadilla_<%= @plural_route %>_path
45
- else
46
- flash.now[:warning] = 'There were problems when trying to update this <%= singular_name.humanize.downcase %>'
47
- render :action => :show
48
- end
49
- end
50
-
51
- def destroy
52
- @<%= singular_name %> = <%= class_name %>.find params[:id]
53
-
54
- @<%= singular_name %>.destroy
55
- flash[:notice] = '<%= singular_name.humanize.capitalize %> has been deleted'
56
- redirect_to caseadilla_<%= @plural_route %>_path
57
- end
58
-
59
- private
60
- <%
61
- permit_list = ""
62
- attributes.each_with_index {|attribute|
63
- permit_list += ", " unless permit_list.empty?
64
- permit_list += ":#{attribute.name}"
65
- }
66
- %>
67
- def <%= singular_name %>_params
68
- params.require(:<%= singular_name %>).permit(<%= permit_list %>)
69
- end
70
- <% end %>
71
- end
1
+ # Scaffolding generated by Caseadilla <%= caseadilla_get_full_version_string %>
2
+
3
+ module Caseadilla
4
+ class <%= class_name.pluralize %>Controller < Caseadilla::CaseadillaController
5
+
6
+ ## optional filters for defining usage according to Caseadilla::AdminUser access_levels
7
+ # before_filter :needs_admin, :except => [:action1, :action2]
8
+ # before_filter :needs_admin_or_current_user, :only => [:action1, :action2]
9
+ <% unless @no_index %>
10
+ def index
11
+ @caseadilla_page_title = '<%= plural_name.humanize.capitalize %>'
12
+ @<%= plural_name %> = <%= class_name %>.order(sort_order(:<%= attributes[0].name %>)).paginate :page => params[:page]
13
+ end
14
+ <% end %>
15
+ def show
16
+ @caseadilla_page_title = 'View <%= singular_name.humanize.downcase %>'
17
+ @<%= singular_name %> = <%= class_name %>.find params[:id]
18
+ end
19
+ <% unless @read_only %>
20
+ def new
21
+ @caseadilla_page_title = 'Add a new <%= singular_name.humanize.downcase %>'
22
+ @<%= singular_name %> = <%= class_name %>.new
23
+ end
24
+
25
+ def create
26
+ @<%= singular_name %> = <%= class_name %>.new <%= singular_name %>_params
27
+
28
+ if @<%= singular_name %>.save
29
+ flash[:notice] = '<%= singular_name.humanize.capitalize %> created'
30
+ redirect_to caseadilla_<%= @plural_route %>_path
31
+ else
32
+ flash.now[:warning] = 'There were problems when trying to create a new <%= singular_name.humanize.downcase %>'
33
+ render :action => :new
34
+ end
35
+ end
36
+
37
+ def update
38
+ @caseadilla_page_title = 'Update <%= singular_name.humanize.downcase %>'
39
+
40
+ @<%= singular_name %> = <%= class_name %>.find params[:id]
41
+
42
+ if @<%= singular_name %>.update_attributes <%= singular_name %>_params
43
+ flash[:notice] = '<%= singular_name.humanize.capitalize %> has been updated'
44
+ redirect_to caseadilla_<%= @plural_route %>_path
45
+ else
46
+ flash.now[:warning] = 'There were problems when trying to update this <%= singular_name.humanize.downcase %>'
47
+ render :action => :show
48
+ end
49
+ end
50
+
51
+ def destroy
52
+ @<%= singular_name %> = <%= class_name %>.find params[:id]
53
+
54
+ @<%= singular_name %>.destroy
55
+ flash[:notice] = '<%= singular_name.humanize.capitalize %> has been deleted'
56
+ redirect_to caseadilla_<%= @plural_route %>_path
57
+ end
58
+
59
+ private
60
+ <%
61
+ permit_list = ""
62
+ attributes.each_with_index {|attribute|
63
+ permit_list += ", " unless permit_list.empty?
64
+ permit_list += ":#{attribute.name}"
65
+ }
66
+ %>
67
+ def <%= singular_name %>_params
68
+ params.require(:<%= singular_name %>).permit(<%= permit_list %>)
69
+ end
70
+ <% end %>
71
+ end
72
72
  end