H
Henrik
This is a Rails example, but I think the problem is a general Ruby
matter.
I am using class_eval within a class method, foobar(), to have it create
an instance method, get_foobar(). I am passing a value ("testing testing
123") to foobar() that I want to make part of get_foobar(). However, I
can't seem to include this value in the output of get_foobar().
Where I want the "render" line to output "A start testing testing 123
end O", it only outputs "A start end O". Extremely grateful for any
help. Code:
class HelpController < ApplicationController
def self.foobar(v)
class_eval %q{
def get_foobar()
"start #{v} end"
end
}
end
foobar "testing testing 123"
def index
render :text => "A "+get_foobar+" O"
end
end
Or syntax highlighted here: http://rafb.net/paste/results/igothN18.html
matter.
I am using class_eval within a class method, foobar(), to have it create
an instance method, get_foobar(). I am passing a value ("testing testing
123") to foobar() that I want to make part of get_foobar(). However, I
can't seem to include this value in the output of get_foobar().
Where I want the "render" line to output "A start testing testing 123
end O", it only outputs "A start end O". Extremely grateful for any
help. Code:
class HelpController < ApplicationController
def self.foobar(v)
class_eval %q{
def get_foobar()
"start #{v} end"
end
}
end
foobar "testing testing 123"
def index
render :text => "A "+get_foobar+" O"
end
end
Or syntax highlighted here: http://rafb.net/paste/results/igothN18.html