我有以下before_filter
:共享代碼的respond_to塊
def find_current_membership
respond_to do |wants|
wants.html { @current_membership = @group.memberships.for(@current_user) }
wants.rss {}
wants.js { @current_membership = @group.memberships.for(@current_user) }
end
end
我想和大家分享的代碼爲HTML和JS塊。有沒有更好的方法,而不是將代碼投入方法?我希望這會工作:
def find_current_membership
respond_to do |wants|
wants.rss {}
wants.all { @current_membership = @group.memberships.for(@current_user) }
end
end
但唉,它沒有。