0
我是相當新的鐵軌,我有麻煩呈現json文件。我在我的帳戶控制這個動作:rails 2.3.5動作呈現json帳戶/圖像,而不是帳戶/ images.json
def images
user = current_user #|| current_fb_user
img_urls = []
user.images.each do |img|
unless img.deleted_at || !img.verified_to_s3
img_urls << img.url
end
end
render :json => img_urls
end
此呈現一個JSON,但它使得它在「/帳號/圖像」,而不是「/accounts/images.json」(我得到一個模板丟失時,我嘗試images.json)作爲一個實際的.json文件。我如何編寫代碼,以便我可以得到一個.json文件?
感謝
respond_with似乎是rails 3.x,所以我不能使用它。 – Zyren
您正在使用哪種版本的導軌?你有沒有嘗試過使用「img_urls.to_json?」 ? –