忍不住尝试重新启动的RailsForum并在此处交叉发布此问题。
我有以下表单对象(在 Rails 4 中)
class StationForm
include Virtus
include ActiveModel::Model
# I think this is unnecessary
# extend ActiveModel::Naming
# include ActiveModel::Conversion
# include ActiveModel::Validations
# Station
attr_reader :station
attribute :station_name, String
attribute :station_description, String
# Address
attr_reader :address
attribute :address_url, String
attribute :address_priority, Integer
attribute :address_is_active, Boolean
def persisted?
false
end
def save
if valid?
persist
true
else
false
end
end
private
def persist
@station = Station.create(name: station_name, description: station_description)
@address = …Run Code Online (Sandbox Code Playgroud) 我有一个简单的应用程序上传我在博客数据库中使用carrierwave保存的图片.(有标题,正文和图像),我的证书工作正常.
我使用此网址在s3帐户中上传了一张图片:/s3.amazonaws.com/Buket_name/..path../thumb_smile.png
如何使用heroku rails控制台中的映像更新数据库.这似乎不起作用:
b = Blog.new
b.title = "a blog"
b.body = "some text"
b.image = File.new("s3.amazonaws.com/Buket_name/..path../thumb_smile.png","a")
or
b.image = File.open("s3.amazonaws.com/Buket_name/..path../thumb_smile.png","r")
Errno::ENOENT: No such file or directory -
s3.amazonaws.com/Buket_name/..path../thumb_smile.png
Run Code Online (Sandbox Code Playgroud)