# Generator problem; ERB seems not to work - HELP needed

**URL:** <https://www.ruby-forum.com/t/generator-problem-erb-seems-not-to-work-help-needed/116963>\
**Category:** Rails\
**Created:** [October 11, 2007, 6:27pm UTC](https://www.ruby-forum.com/t/generator-problem-erb-seems-not-to-work-help-needed/116963 "2007-10-11T18:27:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Feurio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3bc359/32.png) [@Feurio](https://www.ruby-forum.com/u/Feurio)\
**Post date:** [October 11, 2007, 6:27pm UTC](https://www.ruby-forum.com/t/generator-problem-erb-seems-not-to-work-help-needed/116963/1 "2007-10-11T18:27:50Z")

</div>

Hello folks,

I do have a hard time with a generator that come with the active  
active-rbac-plugin (v0.5).  
In order to find the source of the problem I did compare the existing  
controller generator with the active-rbac one.

With the same version of ruby (1.8.6), rails (1.2.4) and windows xp  
pro this works

ruby script/generate controller Admin index

and this doesn´t

ruby script/generate rbac\_bootstrap Test

With the later one I get the following error message:

undefined method `error_messages_for' for #<Rails::Generator::Commands::Create:0x470d470> C:/Programme/InstantRails/Rails_1_2_4/ruby/lib/ruby/1.8/delegate.rb: 268:in`method\_missing’  
(erb):12:in `template' C:/Programme/InstantRails/Rails_1_2_4/ruby/ lib/ruby/gems/1.8/gems/rails-1.2.4/lib/rails_generator/commands.rb: 280:in`template’ C:/Programme/InstantRails/Rails\_1\_2\_4/ruby/lib/ruby/  
gems/1.8/gems/rails-1.2.4/lib/rails\_generator/commands.rb:257:in  
`identical?' C:/Programme/InstantRails/Rails_1_2_4/ruby/lib/ruby/gems/ 1.8/gems/rails-1.2.4/lib/rails_generator/commands.rb:257:in`open’ C:/  
Programme/InstantRails/Rails\_1\_2\_4/ruby/lib/ruby/gems/1.8/gems/  
rails-1.2.4/lib/rails\_generator/commands.rb:257:in `identical?' C:/ Programme/InstantRails/Rails_1_2_4/ruby/lib/ruby/gems/1.8/gems/ rails-1.2.4/lib/rails_generator/commands.rb:203:in`file’ C:/  
Programme/InstantRails/Rails\_1\_2\_4/ruby/lib/ruby/gems/1.8/gems/  
rails-1.2.4/lib/rails\_generator/commands.rb:277:in `template' C:/ Programme/InstantRails/Rails_1_2_4/ruby/lib/ruby/gems/1.8/gems/ rails-1.2.4/lib/rails_generator/manifest.rb:47:in`send’ C:/Programme/  
InstantRails/Rails\_1\_2\_4/ruby/lib/ruby/gems/1.8/gems/rails-1.2.4/lib/  
rails\_generator/manifest.rb:47:in `send_actions' C:/Programme/ InstantRails/Rails_1_2_4/ruby/lib/ruby/gems/1.8/gems/rails-1.2.4/lib/ rails_generator/manifest.rb:46:in`each’ C:/Programme/InstantRails/  
Rails\_1\_2\_4/ruby/lib/ruby/gems/1.8/gems/rails-1.2.4/lib/  
rails\_generator/manifest.rb:46:in `send_actions' C:/Programme/ InstantRails/Rails_1_2_4/ruby/lib/ruby/gems/1.8/gems/rails-1.2.4/lib/ rails_generator/manifest.rb:31:in`replay’  
C:/Programme/InstantRails/Rails\_1\_2\_4/ruby/lib/ruby/gems/1.8/gems/  
rails-1.2.4/lib/rails\_generator/commands.rb:42:in `invoke!' C:/ Programme/InstantRails/Rails_1_2_4/ruby/lib/ruby/gems/1.8/gems/ rails-1.2.4/lib/rails_generator/scripts/../scripts.rb:31:in`run’  
C:/Programme/InstantRails/Rails\_1\_2\_4/ruby/lib/ruby/gems/1.8/gems/  
rails-1.2.4/lib/commands/generate.rb:6  
C:/Programme/InstantRails/Rails\_1\_2\_4/ruby/lib/ruby/site\_ruby/1.8/  
rubygems/custom\_require.rb:27:in `gem_original_require' C:/Programme/InstantRails/Rails_1_2_4/ruby/lib/ruby/site_ruby/1.8/ rubygems/custom_require.rb:27:in`require’  
script/generate:3

* * *

As far as I can see I think it has something to do with ERB. It seems  
not to know the ‘error\_messages\_for’ helper.  
What can be the reason?

The rbac\_bootstrap\_generator.rb files looks like this:

* * *

class RbacBootstrapGenerator \< Rails::Generator::NamedBase  
def manifest  
record do |m|  
m.directory File.join(‘app/controllers’)  
m.directory File.join(‘app/models’)  
m.directory File.join(‘app/views/auth’)  
m.directory File.join(‘test/unit’)  
m.directory File.join(‘test/functional’)

```
  # create controller files
  m.template 'auth_controller.rb', 'app/controllers/

```

auth\_controller.rb’

```
  # create views
  %w( login logout ).each do |str|
    name = "#{str}.rhtml"
    path = "app/views/auth/#{str}.rhtml"
    m.template name, path
  end

  # create controller tests
  m.template 'auth_controller_test.rb', 'test/functional/

```

auth\_controller\_test.rb’

```
  # create models and tests
  %w( anonymous_user user role static_permission ).each do |str|
    m.template "#{str}.rb", "app/models/#{str}.rb"
    m.template "#{str}_test.rb", "test/unit/#{str}_test.rb"
  end

  # create fixtures
  %w( users roles static_permissions ).each do |str|
    m.template "#{str}.yml", "test/fixtures/#{str}.yml"
  end

  # create migrations
  m.migration_template 'add_rbac_schema.rb', 'db/migrate',
    :migration_file_name => "add_rbac_schema"
  m.migration_template 'insert_rbac_records.rb', 'db/migrate',
    :migration_file_name => "insert_rbac_records"

  # modify application_controller.rb
  file_contents = File.read('app/controllers/application.rb')

  if file_contents.match(/ActionController::Base/).nil? then
    file_contents << %Q{

```

# COULD NOT FIND substring “ActionController::Base”! You have to add

the

# following line manually to your ApplicationController:

# 

# acts\_as\_current\_user\_container :anonymous\_user =\> AnonymousUser

}  
else  
file\_contents.gsub!(/ActionController::Base/, “\0\n  
acts\_as\_anonymous\_user :anonymous\_user =\> AnonymousUser”)  
end

```
  File.open('app/controllers/application.rb', 'w') do |f|
    f.write(file_contents)
  end
end

```

end  
end
