I'm simply trying to write to a CSV file in dev with thin, but I am continually getting an error that says No such file or directory - http://localhost:3000/assets/tplan_log.csv
我只是想用dev写入dev中的CSV文件,但是我不断收到一个错误,上面写着没有这样的文件或目录 - http:// localhost:3000 / assets / tplan_log.csv
However, my config looks like this:
但是,我的配置如下所示:
development.rb
development.rb
config.serve_static_assets = true
config.serve_static_assets = true
And my controller looks like this:
我的控制器看起来像这样:
def csv
#this returns a valid path
log_path = view_context.asset_path 'plan_log.csv'
#error occurs here
CSV.open(log_path) do |csv|
csv << ["row","row1","row2"]
end
respond_to do |format|
format.js {render json: @diaggroup.errors, status: :unprocessable_entity}
end
end
Rails 3.2.12
Rails 3.2.12
Edit: To clarify, I'm looking for an answer on how to serve this file in development so that it is accessible. I know it's being served with asset pipeline, but there is no get method associated with it, so it's not able to be accessed.
编辑:为了澄清,我正在寻找一个关于如何在开发中提供此文件的答案,以便可以访问它。我知道它正在使用资产管道,但是没有与之关联的get方法,因此无法访问它。
1 个解决方案
#1
0
This ended up being an issue with reference.
这最终成为参考问题。
I was using a reference such as:
我使用的参考文献如下:
http://path/to/file.jpg
HTTP://path/to/file.jpg
Rails wants:
Rails希望:
/path/to/file.jpg
/path/to/file.jpg
#1
0
This ended up being an issue with reference.
这最终成为参考问题。
I was using a reference such as:
我使用的参考文献如下:
http://path/to/file.jpg
HTTP://path/to/file.jpg
Rails wants:
Rails希望:
/path/to/file.jpg
/path/to/file.jpg