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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---