vendredi 17 janvier 2020

How to acess has_many_through file urls of file uploaded using carrierwave in rails

How can I access the url of the file which is present in the related model and uploaded by using carrier wave. I have three Models like:

class ThreeDModel < ApplicationRecord
  has_many :three_d_model_animations
  has_many :animations, through: :three_d_model_animations
end

2nd

class Animation < ApplicationRecord
  has_many :three_d_model_animations
  has_many :three_d_models, through: :three_d_model_animations
  mount_uploader :video, AnimationVideoUploader
  validates_presence_of :video
end

3rd

class ThreeDModelAnimation < ApplicationRecord
  belongs_to :animation
  belongs_to :three_d_model
  validates_presence_of :animation_file
  mount_uploader :animation_file, ThreeDModelAnimationUploader
end

so, now I want to access the url of the video which is present in the Animation model uploaded using carrier wave,along with the fields in the ThreeDModelAnimation and url of the aimation file.
Because if go with the joins and select query the url to the files will be lost. please tell me how to acheive it without loosing the file_url to the file. Thanks in advance

Aucun commentaire:

Enregistrer un commentaire