lipsiadmin 5.1.6 → 5.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/lib/access_control/authentication.rb +20 -20
  2. data/lib/access_control/base.rb +40 -40
  3. data/lib/controller/ext.rb +27 -27
  4. data/lib/controller/lipsiadmin_controller.rb +3 -3
  5. data/lib/controller/pdf_builder.rb +33 -31
  6. data/lib/controller/rescue.rb +12 -12
  7. data/lib/controller/responds_to_parent.rb +5 -5
  8. data/lib/data_base/attachment.rb +60 -60
  9. data/lib/data_base/attachment/attach.rb +18 -18
  10. data/lib/data_base/attachment/geometry.rb +7 -7
  11. data/lib/data_base/attachment/iostream.rb +1 -1
  12. data/lib/data_base/attachment/processor.rb +2 -2
  13. data/lib/data_base/attachment/storage.rb +11 -11
  14. data/lib/data_base/attachment/thumbnail.rb +2 -2
  15. data/lib/data_base/attachment_table.rb +27 -27
  16. data/lib/data_base/translate_attributes.rb +9 -9
  17. data/lib/data_base/utility_scopes.rb +7 -7
  18. data/lib/data_base/without_table.rb +10 -10
  19. data/lib/generator.rb +4 -4
  20. data/lib/loops.rb +77 -77
  21. data/lib/loops/base.rb +2 -2
  22. data/lib/loops/daemonize.rb +5 -5
  23. data/lib/loops/process_manager.rb +3 -3
  24. data/lib/loops/worker.rb +1 -1
  25. data/lib/loops/worker_pool.rb +1 -1
  26. data/lib/mailer/exception_notifier.rb +5 -5
  27. data/lib/mailer/pdf_builder.rb +20 -18
  28. data/lib/utils/literal.rb +6 -6
  29. data/lib/utils/pdf_builder.rb +10 -10
  30. data/lib/version.rb +1 -1
  31. data/lib/view/helpers/backend_helper.rb +123 -123
  32. data/lib/view/helpers/ext/button.rb +7 -7
  33. data/lib/view/helpers/ext/column_model.rb +18 -18
  34. data/lib/view/helpers/ext/component.rb +50 -50
  35. data/lib/view/helpers/ext/configuration.rb +5 -5
  36. data/lib/view/helpers/ext/grid.rb +46 -46
  37. data/lib/view/helpers/ext/store.rb +14 -14
  38. data/lib/view/helpers/ext/tool_bar.rb +6 -6
  39. data/lib/view/helpers/ext_helper.rb +21 -21
  40. data/lib/view/helpers/frontend_helper.rb +5 -5
  41. data/lib/view/helpers/pdf_helper.rb +7 -7
  42. data/lib/view/helpers/view_helper.rb +28 -28
  43. data/lipsiadmin_generators/attachment/attachment_generator.rb +7 -7
  44. data/lipsiadmin_generators/attachment/templates/controller.rb +13 -13
  45. data/lipsiadmin_generators/attachment/templates/migration.rb +1 -1
  46. data/lipsiadmin_generators/backend/backend_generator.rb +9 -9
  47. data/lipsiadmin_generators/backend/templates/controllers/backend/accounts_controller.rb +10 -10
  48. data/lipsiadmin_generators/backend/templates/controllers/backend/sessions_controller.rb +2 -2
  49. data/lipsiadmin_generators/backend/templates/controllers/javascripts_controller.rb +2 -2
  50. data/lipsiadmin_generators/backend/templates/migrations/create_accounts.rb +5 -5
  51. data/lipsiadmin_generators/backend/templates/models/account.rb +16 -16
  52. data/lipsiadmin_generators/backend/templates/models/account_access.rb +11 -11
  53. data/lipsiadmin_generators/backend/templates/models/notifier.rb +2 -2
  54. data/lipsiadmin_generators/backend_page/backend_page_generator.rb +22 -22
  55. data/lipsiadmin_generators/backend_page/templates/controller.rb +9 -9
  56. data/lipsiadmin_generators/backend_page/templates/functional_test.rb +10 -10
  57. data/lipsiadmin_generators/frontend/frontend_generator.rb +5 -5
  58. data/lipsiadmin_generators/frontend/templates/controllers/frontend/sessions_controller.rb +3 -3
  59. data/lipsiadmin_generators/loops/loops_generator.rb +2 -2
  60. data/lipsiadmin_generators/pdf/pdf_generator.rb +7 -7
  61. data/lipsiadmin_generators/state_session/state_session_generator.rb +9 -9
  62. data/lipsiadmin_generators/state_session/templates/controller.rb +2 -2
  63. data/lipsiadmin_generators/state_session/templates/migration.rb +2 -2
  64. data/resources/rdoc/horo.rb +3 -3
  65. metadata +4 -4
@@ -1,7 +1,7 @@
1
1
  class AttachmentGenerator < Rails::Generator::Base
2
2
  default_options :skip_migration => false
3
-
4
- def manifest
3
+
4
+ def manifest
5
5
  record do |m|
6
6
  unless options[:skip_migration]
7
7
  m.migration_template("migration.rb", "db/migrate", :migration_file_name => "create_attachments")
@@ -11,21 +11,21 @@ class AttachmentGenerator < Rails::Generator::Base
11
11
  m.directory('app/models')
12
12
  m.template('model.rb', 'app/models/attachment.rb')
13
13
  m.template('controller.rb', 'app/controllers/backend/attachments_controller.rb')
14
- m.readme "../REMEMBER"
14
+ m.readme "../REMEMBER"
15
15
  end
16
- end
16
+ end
17
17
 
18
18
 
19
19
  protected
20
20
  def banner
21
21
  "Usage: #{$0} attachment [--skip-migration]"
22
22
  end
23
-
23
+
24
24
  def add_options!(opt)
25
25
  opt.separator ''
26
26
  opt.separator 'Options:'
27
27
  opt.on("--skip-migration",
28
28
  "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
29
29
  end
30
-
31
- end
30
+
31
+ end
@@ -2,26 +2,26 @@ class Backend::AttachmentsController < BackendController
2
2
 
3
3
  def index
4
4
  params[:limit] ||= 50
5
-
5
+
6
6
  @column_store = column_store_for Attachment do |cm|
7
7
  cm.add :attacher_type
8
8
  cm.add :attached_file_name
9
9
  cm.add :attached_content_type
10
10
  cm.add :attached_file_size
11
11
  cm.add :position
12
- cm.add :created_at, :renderer => :datetime
13
- cm.add :updated_at, :renderer => :datetime
12
+ cm.add :created_at, :renderer => :datetime
13
+ cm.add :updated_at, :renderer => :datetime
14
14
  end
15
-
15
+
16
16
  respond_to do |format|
17
- format.js
17
+ format.js
18
18
  format.json do
19
19
  render :json => @column_store.store_data(params)
20
20
  end
21
21
  end
22
22
  end
23
23
 
24
-
24
+
25
25
  def new
26
26
  @attachment = Attachment.new
27
27
  end
@@ -40,14 +40,14 @@ class Backend::AttachmentsController < BackendController
40
40
  end
41
41
 
42
42
  def update
43
- @attachment = Attachment.find(params[:id])
43
+ @attachment = Attachment.find(params[:id])
44
44
  if @attachment.update_attributes(params[:attachment])
45
45
  redirect_parent_to(:action => "edit", :id => @attachment)
46
46
  else
47
47
  render_to_parent(:action => "edit")
48
- end
48
+ end
49
49
  end
50
-
50
+
51
51
  def order
52
52
  # We Need to search the correct params
53
53
  ordering = params.find { |k,v| k.to_s =~ /-order$/ }[1]
@@ -58,14 +58,14 @@ class Backend::AttachmentsController < BackendController
58
58
  rescue
59
59
  render :text => "Params for ordering not found, call it some-order"
60
60
  end
61
-
62
- # Add in your model before_destroy and if the callback returns false,
61
+
62
+ # Add in your model before_destroy and if the callback returns false,
63
63
  # all the later callbacks and the associated action are cancelled.
64
64
  def destroy
65
65
  if Attachment.find(params[:id]).destroy
66
- render :json => { :success => true }
66
+ render :json => { :success => true }
67
67
  else
68
68
  render :json => { :success => false, :msg => I18n.t("backend.general.cantDelete") }
69
69
  end
70
70
  end
71
- end
71
+ end
@@ -1,7 +1,7 @@
1
1
  class CreateAttachments < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :attachments, :force => true do |t|
4
- t.string :attached_file_name
4
+ t.string :attached_file_name
5
5
  t.string :attached_content_type
6
6
  t.integer :attached_file_size
7
7
  t.references :attacher, :polymorphic => true
@@ -11,7 +11,7 @@ class BackendGenerator < Rails::Generator::Base
11
11
  map.backend '/backend', :controller => 'backend/base', :action => 'index'
12
12
  map.connect '/javascripts/:action.:format', :controller => 'javascripts'
13
13
  ROUTES
14
-
14
+
15
15
  lipsiadmin_task = <<-EOF
16
16
  begin
17
17
  gem 'lipsiadmin'
@@ -19,14 +19,14 @@ begin
19
19
  rescue Gem::LoadError
20
20
  end
21
21
  EOF
22
-
22
+
23
23
  record do |m|
24
24
  m.directory("app/views/exceptions")
25
-
25
+
26
26
  m.append("config/routes.rb", routes, "ActionController::Routing::Routes.draw do |map|")
27
27
  m.append("public/robots.txt", "User-agent: *\nDisallow: /backend")
28
28
  m.append("Rakefile", lipsiadmin_task)
29
-
29
+
30
30
  m.create_all("controllers", "app/controllers")
31
31
  m.create_all("helpers", "app/helpers")
32
32
  m.create_all("images", "public/images")
@@ -37,7 +37,7 @@ end
37
37
  m.create_all("views", "app/views")
38
38
  m.create_all("config", "config")
39
39
  m.create_all("test", "test")
40
-
40
+
41
41
  # Using this for prevent raising errors
42
42
  migration = Dir.glob("db/migrate/[0-9]*_*.rb").grep(/[0-9]+_create_accounts.rb$/)
43
43
  if migration.empty?
@@ -45,12 +45,12 @@ end
45
45
  else
46
46
  logger.exists migration.first
47
47
  end
48
-
48
+
49
49
  %w(404 422 500).each do |page|
50
50
  m.template("exceptions/template.html.haml", "app/views/exceptions/#{page}.html.haml", :assigns => { :status_code => page })
51
51
  end
52
-
53
- m.readme "../REMEMBER"
52
+
53
+ m.readme "../REMEMBER"
54
54
  end
55
55
  end
56
56
 
@@ -58,4 +58,4 @@ end
58
58
  def banner
59
59
  "Usage: #{$0} backend"
60
60
  end
61
- end
61
+ end
@@ -8,9 +8,9 @@ class Backend::AccountsController < BackendController
8
8
  cm.add :created_at, :renderer => :datetime, :align => :right
9
9
  cm.add :updated_at, :renderer => :datetime, :align => :right
10
10
  end
11
-
11
+
12
12
  respond_to do |format|
13
- format.js
13
+ format.js
14
14
  format.json do
15
15
  render :json => @column_store.store_data(params)
16
16
  end
@@ -20,7 +20,7 @@ class Backend::AccountsController < BackendController
20
20
  def new
21
21
  @account = Account.new
22
22
  end
23
-
23
+
24
24
  def create
25
25
  @account = Account.new(params[:account])
26
26
  if @account.save
@@ -29,25 +29,25 @@ class Backend::AccountsController < BackendController
29
29
  render_to_parent(:action => "new")
30
30
  end
31
31
  end
32
-
32
+
33
33
  def edit
34
34
  @account = Account.find(params[:id])
35
35
  end
36
-
36
+
37
37
  def update
38
38
  @account = Account.find(params[:id])
39
39
  if @account.update_attributes(params[:account])
40
40
  redirect_parent_to(:action => "edit", :id => @account)
41
41
  else
42
42
  render_to_parent(:action => "edit")
43
- end
43
+ end
44
44
  end
45
-
45
+
46
46
  def destroy
47
47
  if Account.find(params[:id]).destroy
48
- render :json => { :success => true }
48
+ render :json => { :success => true }
49
49
  else
50
50
  render :json => { :success => false, :msg => I18n.t("backend.general.cantDelete") }
51
- end
51
+ end
52
52
  end
53
- end
53
+ end
@@ -1,7 +1,7 @@
1
- # This controller handles the login/logout function of the site.
1
+ # This controller handles the login/logout function of the site.
2
2
  class Backend::SessionsController < ApplicationController
3
3
  layout "backend"
4
-
4
+
5
5
  def create
6
6
  self.current_account = Account.authenticate(params[:email], params[:password])
7
7
  if logged_in?
@@ -1,6 +1,6 @@
1
1
  class JavascriptsController < ApplicationController
2
2
  helper Lipsiadmin::View::Helpers::BackendHelper
3
-
3
+
4
4
  def backend
5
5
  respond_to do |format|
6
6
  format.html { render :text => "Resource is not available, regardless of authorization. Often the result of bad file or directory permissions on the server. ", :status => '403 Forbidden' }
@@ -14,4 +14,4 @@ class JavascriptsController < ApplicationController
14
14
  format.js
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -6,15 +6,15 @@ class CreateAccounts < ActiveRecord::Migration
6
6
  end
7
7
 
8
8
  # I'll create the first account
9
- Account.create({:email => "info@lipsiasoft.com",
10
- :name => "Davide",
9
+ Account.create({:email => "info@lipsiasoft.com",
10
+ :name => "Davide",
11
11
  :surname => "D'Agostino",
12
- :password => "admin",
13
- :password_confirmation => "admin",
12
+ :password => "admin",
13
+ :password_confirmation => "admin",
14
14
  :role => "administrator" })
15
15
  end
16
16
 
17
17
  def self.down
18
18
  drop_table "accounts"
19
19
  end
20
- end
20
+ end
@@ -3,9 +3,9 @@ require 'openssl'
3
3
  class Account < ActiveRecord::Base
4
4
  # Virtual attribute for the unencrypted password
5
5
  attr_accessor :password
6
-
6
+
7
7
  serialize :modules
8
-
8
+
9
9
  # Validations
10
10
  validates_presence_of :name, :surname, :email
11
11
  validates_presence_of :password, :if => :password_required?
@@ -19,24 +19,24 @@ class Account < ActiveRecord::Base
19
19
 
20
20
  # Relations
21
21
  # go here
22
-
22
+
23
23
  # Callbacks
24
24
  before_save :encrypt_password
25
25
  after_create :deliver_registration
26
-
26
+
27
27
  # Named Scopes
28
28
  # go here
29
-
29
+
30
30
  def full_name
31
31
  "#{name} #{surname}".strip
32
32
  end
33
-
34
- # If we don't found a module we need to
33
+
34
+ # If we don't found a module we need to
35
35
  # to return an empty array
36
36
  def modules
37
37
  read_attribute(:modules) || []
38
38
  end
39
-
39
+
40
40
  # We need to perform a little rewrite
41
41
  def modules=(perms)
42
42
  perms = perms.collect {|p| p.to_sym unless p.blank? }.compact if perms
@@ -58,7 +58,7 @@ class Account < ActiveRecord::Base
58
58
  rescue
59
59
  nil
60
60
  end
61
-
61
+
62
62
  # Get the uncripted password
63
63
  def password_clean
64
64
  unless @password
@@ -71,7 +71,7 @@ class Account < ActiveRecord::Base
71
71
  rescue
72
72
  nil
73
73
  end
74
-
74
+
75
75
  # If you want you can integrate you custom activation/blocking system
76
76
  # Our auth system already check this method so don't delete it
77
77
  def active?
@@ -83,11 +83,11 @@ class Account < ActiveRecord::Base
83
83
  self.class.encrypt(password, salt)
84
84
  end
85
85
 
86
- # Check if the db password
86
+ # Check if the db password
87
87
  def authenticated?(password)
88
88
  crypted_password.chomp == encrypt(password).chomp rescue false
89
89
  end
90
-
90
+
91
91
  # Generate Methods takes from AccessControl rules
92
92
  # Example:
93
93
  #
@@ -95,19 +95,19 @@ class Account < ActiveRecord::Base
95
95
  # role == "administrator"
96
96
  # end
97
97
  AccountAccess.roles.each { |r| define_method("#{r.to_s.downcase.gsub(" ","_").to_sym}?") { role.to_s.downcase == r.to_s.downcase } }
98
-
98
+
99
99
  protected
100
100
  def encrypt_password
101
101
  return if password.blank?
102
102
  self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--") if new_record?
103
103
  self.crypted_password = encrypt(password)
104
104
  end
105
-
105
+
106
106
  def password_required?
107
107
  crypted_password.blank? || !password.blank?
108
108
  end
109
-
109
+
110
110
  def deliver_registration
111
111
  Notifier.deliver_registration(self)
112
112
  end
113
- end
113
+ end
@@ -1,32 +1,32 @@
1
- class AccountAccess < Lipsiadmin::AccessControl::Base
1
+ class AccountAccess < Lipsiadmin::AccessControl::Base
2
2
 
3
3
  roles_for :administrator do |role, current_account|
4
4
  # Shared Permission
5
5
  role.allow_all_actions "/backend"
6
6
  role.allow_all_actions "/backend/base"
7
-
7
+
8
8
  # Remember that it will try to translate the menu in your current
9
9
  # locale
10
- #
10
+ #
11
11
  # # Look for: I18n.t("backend.menus.account") in /config/locales/backend/yourlocale.yml
12
12
  # project_module :account
13
13
  # # Look for: I18n.t("backend.menus.list") in /config/locales/backend/yourlocale.yml
14
14
  # project.menu :list
15
- #
15
+ #
16
16
  # It not necessary have a translation you can provide a classic strings like:
17
- #
17
+ #
18
18
  # role.project_module "My Menu Name"
19
- #
19
+ #
20
20
  # <tt>current_account</tt> is an instance of current logged account
21
- #
21
+ #
22
22
  role.project_module :account do |project|
23
23
  project.menu :list, "/backend/accounts.js" do |submenu|
24
24
  submenu.add :new, "/backend/accounts/new"
25
25
  end
26
26
  end
27
-
27
+
28
28
  # Please don't remove this comment! It's used for auto adding project modules
29
29
  end
30
-
31
-
32
- end
30
+
31
+
32
+ end
@@ -5,11 +5,11 @@ class Notifier < ActionMailer::Base
5
5
  subject "[#{AppConfig.project}] #{I18n.t('backend.emails.registration.object')}"
6
6
  body :account => account, :url => "#{AppConfig.host_addr}/backend"
7
7
  end
8
-
8
+
9
9
  def support_request(account, message)
10
10
  from account.email
11
11
  recipients AppConfig.email_help
12
12
  subject "[#{AppConfig.project}] #{I18n.t('backend.emails.support.object')}"
13
13
  body :message => message
14
14
  end
15
- end
15
+ end
@@ -2,18 +2,18 @@ class ScaffoldingSandbox
2
2
  include ActionView::Helpers::ActiveRecordHelper
3
3
 
4
4
  attr_accessor :form_action, :singular_name, :suffix, :model_instance
5
-
5
+
6
6
  INVALID_COLUMNS = ["_file_name","_content_type","_file_size","created_at","updated_at"]
7
-
7
+
8
8
  def all_input_tags(record, record_name, options)
9
9
  input_block = options[:input_block] || default_input_block
10
10
  record.class.content_columns.collect{ |column| input_block.call(record_name, column) if is_valid?(column) }.compact.join("\n")
11
11
  end
12
-
12
+
13
13
  def sandbox_binding
14
14
  binding
15
15
  end
16
-
16
+
17
17
  def default_input_block
18
18
  Proc.new do |record, column|
19
19
  " %tr
@@ -21,7 +21,7 @@ class ScaffoldingSandbox
21
21
  %td#{input(record, column.name)}"
22
22
  end
23
23
  end
24
-
24
+
25
25
  def is_valid?(column)
26
26
  !INVALID_COLUMNS.find { |c| column.name.include?(c) }
27
27
  end
@@ -44,11 +44,11 @@ class ActionView::Helpers::InstanceTag
44
44
  def to_datetime_select_tag(options = {})
45
45
  "=ext_datetime_select :#{@object_name}, :#{@method_name}#{options.empty? ? '' : ', '+ options.inspect}"
46
46
  end
47
-
47
+
48
48
  def to_time_select_tag(options = {})
49
49
  "=time_select :#{@object_name}, :#{@method_name}#{options.empty? ? '' : ', '+ options.inspect}"
50
50
  end
51
-
51
+
52
52
  def to_boolean_select_tag(options = {})
53
53
  "=check_box :#{@object_name}, :#{@method_name}#{options.empty? ? '' : ', '+ options.inspect}"
54
54
  end
@@ -64,11 +64,11 @@ class BackendPageGenerator < Rails::Generator::NamedBase
64
64
  :controller_underscore_name,
65
65
  :controller_singular_name,
66
66
  :controller_plural_name,
67
- :files, :images,
67
+ :files, :images,
68
68
  :with_files, :with_images, :with_attachments
69
69
  alias_method :controller_file_name, :controller_underscore_name
70
70
  alias_method :controller_table_name, :controller_plural_name
71
-
71
+
72
72
  def initialize(runtime_args, runtime_options = {})
73
73
  super
74
74
  @controller_name = @name.pluralize
@@ -77,7 +77,7 @@ class BackendPageGenerator < Rails::Generator::NamedBase
77
77
  base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
78
78
  @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
79
79
  @controller_singular_name=base_name.singularize
80
-
80
+
81
81
  if @controller_class_nesting.empty?
82
82
  @controller_class_name = @controller_class_name_without_nesting
83
83
  else
@@ -86,7 +86,7 @@ class BackendPageGenerator < Rails::Generator::NamedBase
86
86
 
87
87
  @with_images, @images = (options[:images] && options[:images].size > 0), options[:images] ||= []
88
88
  @with_files, @files = (options[:files] && options[:files].size > 0), options[:files] ||= []
89
-
89
+
90
90
  @with_attachments = (@with_images || @with_files)
91
91
  end
92
92
 
@@ -96,19 +96,19 @@ class BackendPageGenerator < Rails::Generator::NamedBase
96
96
  # Check for class naming collisions.
97
97
  m.class_collisions controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}ControllerTest", "#{controller_class_name}Helper"
98
98
 
99
- attachments = []
99
+ attachments = []
100
100
  attachments.concat(@images).compact!
101
101
  attachments.concat(@files).compact!
102
-
102
+
103
103
  # Adding new permissions
104
104
  permissions = <<-CODE
105
105
  role.project_module :#{model_instance.class.table_name} do |project|
106
106
  project.menu :list, "/backend/#{@controller_name}.js" do |submenu|
107
107
  submenu.add :new, "/backend/#{@controller_name}/new"
108
108
  end
109
- end
109
+ end
110
110
  CODE
111
-
111
+
112
112
  routes = " backend.resources :#{singular_name.pluralize}"
113
113
  # Adding a new permission
114
114
  m.append("app/models/account_access.rb", permissions, "# Please don't remove this comment! It's used for auto adding project modules")
@@ -147,7 +147,7 @@ class BackendPageGenerator < Rails::Generator::NamedBase
147
147
  controller_class_path,
148
148
  controller_file_name,
149
149
  "index.rjs")
150
-
150
+
151
151
  # Controller class, functional test, helper, and views.
152
152
  m.template 'controller.rb',
153
153
  File.join('app/controllers/backend',
@@ -158,7 +158,7 @@ class BackendPageGenerator < Rails::Generator::NamedBase
158
158
  File.join('test/functional/backend',
159
159
  controller_class_path,
160
160
  "#{controller_file_name}_controller_test.rb")
161
-
161
+
162
162
  m.readme "../REMEMBER"
163
163
  end
164
164
  end
@@ -176,8 +176,8 @@ class BackendPageGenerator < Rails::Generator::NamedBase
176
176
  def scaffold_actions
177
177
  scaffold_views + %w(index create update destroy)
178
178
  end
179
-
180
- def model_name
179
+
180
+ def model_name
181
181
  class_name.demodulize
182
182
  end
183
183
 
@@ -193,7 +193,7 @@ class BackendPageGenerator < Rails::Generator::NamedBase
193
193
  sandbox = ScaffoldingSandbox.new
194
194
  sandbox.singular_name = singular_name
195
195
  begin
196
- sandbox.model_instance = model_instance
196
+ sandbox.model_instance = model_instance
197
197
  sandbox.instance_variable_set("@#{singular_name}", sandbox.model_instance)
198
198
  rescue ActiveRecord::StatementInvalid => e
199
199
  logger.error "Before updating backend_page from new DB schema, try creating a table for your model (#{class_name})"
@@ -202,7 +202,7 @@ class BackendPageGenerator < Rails::Generator::NamedBase
202
202
  sandbox.suffix = suffix
203
203
  sandbox
204
204
  end
205
-
205
+
206
206
  def model_instance
207
207
  base = class_nesting.split('::').inject(Object) do |base, nested|
208
208
  break base.const_get(nested) if base.const_defined?(nested)
@@ -213,4 +213,4 @@ class BackendPageGenerator < Rails::Generator::NamedBase
213
213
  end
214
214
  class_name.constantize.new
215
215
  end
216
- end
216
+ end