2
私はRailsの懸念を書き込み、静的メソッドとRubyの動的なラムダ
class Baz < ActiveRecord::Base
@base = 'awesome'
has_many :comments, ->() { where(have_#{@_base} => true) }
end
のようなものを実行する必要がありますが、ラムダはComment
コンテキストで実行されますよ。私はeval "has_many :comments, ->() { where(have_#{@_base} => true) }"
でハックしました。
eval
なしでこの機能を使用する方法はありますか?
ありがとうございました!