Rails helpers don't work by default?

5 views
Skip to first unread message

John Firebaugh

unread,
Oct 13, 2009, 7:14:37 PM10/13/09
to erector
Here's the relevant setup:

Rails::Initializer.run do |config|
config.gem "erector"
end

ActionController::Routing::Routes.draw do |map|
map.root :controller => "welcome"
end

class WelcomeController < ApplicationController
def index
end
end

class Views::Welcome::Index < Erector::RailsWidget
def content
link_to "Foo", '/bar'
end
end

Here's the error:

NoMethodError in Welcome#index

Showing app/views/welcome/index.rb where line #3 raised:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.link_to

/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/erector-0.7.0/lib/
erector/rails/extensions/rails_widget/rails_helpers.rb:19:in `link_to'

rails_helpers.rb:19 (18 actually, off by one) is looking for a parent,
I guess? Isn't the desired behavior in this scenario for the parent to
be automatically set to the view?

Thanks,
John
Reply all
Reply to author
Forward
0 new messages