My brain hurts, please help.
I’ve beaten my head against the wall for hours trying to figure out
why I cant get the public_filename
is only accessible from the views?
I need to get the full file path in the controller so I can render a
JSON object for Flash to pick up.
products = Product.find(:all,{ :include =>
[:seasons, :collections, :types], :conditions => [“sex=? AND
seasons.id=(?)”,params[:sex] , params[:season] ] })
render :text => products.to_json
Thanks for you help
hi …
i was having a project in front where i was uploading videos. i have
used following definition for over witting the full_filename as
def full_filename
user_id = self.user_id
videopath = attachment_options[:path_prefix].to_s + user_id.to_s +
VIDEO_DIR
file_system_path = videopath
path = File.join(RAILS_ROOT, file_system_path , filename)
end
i m storing my videos in public/swf/videos/user_id/video_id path
so i have stored a constant
DOCUMENT_DIR = ‘public/swf/uploads/’
VIDEO_DIR = ‘/videos/’
in the environment.rb… this way i can access the files…
[email protected] wrote:
My brain hurts, please help.
I’ve beaten my head against the wall for hours trying to figure out
why I cant get the public_filename
is only accessible from the views?
I need to get the full file path in the controller so I can render a
JSON object for Flash to pick up.
products = Product.find(:all,{ :include =>
[:seasons, :collections, :types], :conditions => [“sex=? AND
seasons.id=(?)”,params[:sex] , params[:season] ] })
render :text => products.to_json
Thanks for you help
I believe that public_filename is an instance method, not a stored
attribute, so you’ll need to give to_json some help. to_json, like
to_xml, supports parameters that help you make your rendering more
specific. In this case specifically I think you need to look into
making use of the :include (specify the associations to be part of the
json), and :methods (specify instance methods on the object to be
included).
Check here for more: