моя модель пользователя, как показано ниже user.rb
способ использования включает в себя? с отношением belongs_to, ERROR = неопределенный метод `включает? ' для
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>
Я не понимаю, где я, когда ошибаюсь. Ваша помощь будет высоко оценена
Спасибо. это работает. Теперь я вижу свою ошибку. –