-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upgrade to operate in line with new Rails 3 helper blocks #4
base: master
Are you sure you want to change the base?
Conversation
Hi Fastcatch, I tried your fork and the example of SubNav is not working on Rails 3.2.3 Each time I call the sub_nav witha block, I have the following error :
(eval):1: syntax error, unexpected $undefined
$#<VincentHelper::Nav::S...
^
Extracted source (around line #19):
16:
17: <% nav do |n|
18: n.titi
19: n.sub_nav do |s|
20: s.toto
21: end
22: end
23: %>
If there is no block for the method sub_nav, is working - no error but no display The source code is : module VincentHelper
class Nav < BlockHelpers::Base
#...code....
def titi
"titi"
end
class SubNav < BlockHelpers::Base
#...code...
def toto
"toto"
end
end
end Thanks for your help |
It seems that your code is missing a few "=" signs:
works fine. It's not very convenient but that's as good as it gets. If you want fewer '=' signs (and willing to go back to Rails 2.x output logic), redefine
For the record I tested it on 3.0.7 and ruby 1.8.7 but it shouldn't make any difference. |
Thanks I put the =, but it's not working (eval):1: syntax error, unexpected $undefined
$#<TestHelper::Nav::SubNav:0x3...
^
Extracted source (around line #3):
1: <%= nav do |h| %>
2: <%= h.toto %>
3: <%= h.sub_nav do |m| %>
4: <%= m.titi %>
5: <% end %>
6: <% end %>
The source code module TestHelper
class Nav < BlockHelpers::Base
#...code....
def toto
"toto"
end
class SubNav < BlockHelpers::Base
#...code...
def titi
"titi"
end
end
end
end If I DON'T call sub_nav with a block, like this : <%= nav do |h| %>
<%= h.toto %>
<%= h.sub_nav %>
<% end %> I have no error but it displays : toto
#<TestHelper::Nav::SubNav:0x375c480> |
Sorry to hear. I'll check with newer Rails and ruby when I get to it (perhaps 1-2 days), and I'll get back to you. (I guess it's gonna be the ruby for 1.9.x handles blocks a bit different from 1.8.x.) |
It turns out that changes in Rails (ActiveSupport -- to be more precise) cause the breakdown. See this comment and this commit if interested. (I'm seriously surprised at how few projects/people have complained so far overall...) I seem to have got it fixed, though. Not pretty but does the job. |
Thanks it's workiung ! One thing : For your version , I should put in my gemfile : gem "block_helpers", :git => "git://github.com/fastcatch/block_helpers.git", :ref => "64a28acf0de4" |
modified code to operate in line with the new Rails3 helper block syntax and updated documentation