使用HTTP Live Streaming方法播放实时流时,是否可以读取当前元数据(例如标题和艺术家)?这是一个iPhone收音机应用程序.
我正在尝试使用paperclip将文件上传到s3,并在创建新对象并引用变量时出现此错误:
即:
a = Attachment.new
a.file
NameError: uninitialized constant AWS::S3::Connection
from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:32
from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:31:in `class_eval'
from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:31
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/storage.rb:131:in `extended'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:269:in `extend'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:269:in `initialize_storage'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:51:in `initialize'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:372:in `new'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:372:in `attachment_for'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:270:in `file'
from (irb):6
Run Code Online (Sandbox Code Playgroud)
以下是Attachment模型的样子:
class Attachment < ActiveRecord::Base
belongs_to :post
has_attached_file :file,
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => "/uploads/:attachment/:id/:style/:basename.:extension",
:bucket => 'bucketname',
:s3_permissions => :public_read
end
Run Code Online (Sandbox Code Playgroud) 我想为用户模型提供许多动态属性,例如电话,地址,邮政编码等,但我不想将每个属性添加到数据库中.因此,我创建了一个单独的表,称为UserDetails键值对和a belongs_to :User.
有没有办法以某种方式做一些像这样动态的东西user.phone = "888 888 8888"本质上会调用一个函数:
UserDetail.create(:user => user, :key => "phone", :val => "888 888 8888")
Run Code Online (Sandbox Code Playgroud)
然后有一个匹配的getter:
def phone
UserDetail.find_by_user_id_and_key(user,key).val
end
Run Code Online (Sandbox Code Playgroud)
所有这一切,但提供了许多属性,如电话,邮编,地址等,而不是随意添加大量的getter和setter?