你可以做的是每个Product
模型have_many
核准的用户。当BrainTree向您提供用户为产品付款的确定时,您可以将该用户添加到批准的用户列表中。因此,在您的ProductController
中,您检查current_user是否是已批准的用户,如果是这样,请下载该文件,否则重定向它们。
对于Exsample:
product.rb
class Product < ActiveRecord::Model
has_many approved_users, :class => User
end
product_controller.rb
class ProductController
def download
@product = Product.find_by_id(:id)
if @product.approved_users.includes?(current_user)
# Give them the file
else
flash[:notice] = "You must buy the product first!"
redirect_to product_sales_url(@product)
end
end
end
或类似的东西。我的语法可能有点偏离,但这应该会让你走。
看起来像一个公平的想法.. – Rabbott 2011-03-14 20:44:59