我的用户模型如下图user.rb
has_many :authorised_downloads,
:class_name=>"Downloads",
:primary_key => 'id',
:foreign_key=> :authorised_user_id
下载模型download.rb
belongs_to :authorised_users,
:class_name => "User",
:primary_key => 'id',
:foreign_key=> :authorised_user_id
下载控制器
def download
@download = Download.find(params[:id])
if @download.authorised_users.includes?(current_user)
send_file(@download.upload_file.path,
:filename => @download.name,
:x_sendfile=>true,
:url_based_filename => true )
flash[:notice] = "Your file has been downloaded"
else
flash[:notice] = "You must buy the product first!"
end
end
在我的下载视图中,当我单击下载链接时,if @download.authorised_users.includes?(current_user)
下载控制器中的行突出显示并显示以下错误
undefined method `includes?' for #<User:0x00000005c2ff10>
我不明白我哪里错了。您的帮助将不胜感激