我试图让Capistrano第一次在rails应用程序中运行.我有一个运行Ubuntu 12.04,nginx,unicorn和rails的linux服务器,但是,我似乎遇到了一些问题.我也使用Capistrano 3.0.0,rails 3.2.14,bundler 1.4.0和ruby 1.9.3p448使用RVM.
我只设置了一个生产阶段,此时我只关心Capistrano与我的服务器通信并从github推送我的代码(暂时没有迁移和捆绑等).
当我尝试使用下面的设置命令cap production deploy:check
或 cap production deploy:setup
(似乎已弃用?)时,我收到以下错误信息:
我不确定从哪里开始这个错误,谷歌并没有多少建议.我试过添加rvm-capistrano
宝石但无济于事.如何修改代码以解决此错误?
cap aborted!
undefined method `instance' for Capistrano::Configuration:Class
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.4.0.rc.1/lib/bundler/capistrano.rb:11:in `<top (required)>'
config/deploy.rb:1:in `<top (required)>'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/lib/capistrano/setup.rb:12:in `load'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/lib/capistrano/setup.rb:12:in `block (2 levels) in <top (required)>'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/lib/capistrano/application.rb:12:in `run'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/bin/cap:3:in `<top (required)>'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/bin/cap:23:in `load'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/bin/cap:23:in `<main>'
Tasks: TOP => production
(See full trace by running task with --trace)
Run Code Online (Sandbox Code Playgroud)
deploy.rb
require "bundler/capistrano"
set :stages, %w(staging production)
set :default_stage, "production"
set :application, "my_app"
set :user, "andrew"
set :scm, …
Run Code Online (Sandbox Code Playgroud) 我的应用程序模板中有2个命名出口,slider-area
并且pre-footer
.有没有办法将带参数的视图组件(如main-slider
索引模板中显示的组件)传递给指定的插座?所以我需要传递{{main-slider sliders=filteredSlider}}
到{{outlet "slider-area"}}
索引模板中的插座?
我来自rails,所以原谅我的想法,如果这不是ember的做法.可以yield :slider_area
在应用程序模板中指定,然后在content_for :slider_area
块中包装此区域的任何内容.在ember中有类似的方法吗?
的index.html
<script type="text/x-handlebars" data-template-name="application">
{{panasonic-topbar}}
<div id="batterywrap">
{{outlet "slider-area"}}
<div class="index_contents">
<div class="index_contents_inner">
<div class="main_area">
{{outlet}}
</div>
</div>
</div>
</div>
{{panasonic-footer}}
</script>
<script type="text/x-handlebars" data-template-name="index">
# Something like {{outlet "slider-area" render main-slider sliders="filteredSlider}} ?
{{main-slider sliders=filteredSlider}}
{{partial "social_footer"}}
</script>
Run Code Online (Sandbox Code Playgroud)
app.js
App.IndexController = Ember.ObjectController.extend({
filteredSlider: function(){
return this.get('sliders').filterBy('page', 'index');
}.property('sliders.@each.page')
});
App.IndexRoute = Ember.Route.extend({
model: function() {
return Ember.RSVP.hash({
sliders: this.store.find("slider") …
Run Code Online (Sandbox Code Playgroud) 请查看下面的片段。我正在使用 jQuery fileUpload 和直接 s3 表单将视频上传到 AWS。我希望在视频到达任何本地服务器之前施加 5mb 的文件大小限制。如何修改此代码,以便完全停止上传并在文件大小超过 5mb 时提醒用户,如果小于,一切照常进行?
我在 S3 表单选项中添加了 5mb 的内容长度限制,因此拒绝上传大于此值的内容,但是如果有什么东西可以通知用户上传太大而无法开始,那将是可取的。
$ ->
$(".direct-upload").each ->
form = $(this)
$(this).fileupload
url: form.attr("action")
type: "POST"
autoUpload: true
dataType: "xml"
add: (event, data) ->
if data.files[0].size < 5242880
$.ajax
url: "/signed_urls"
type: "GET"
dataType: "json"
data:
doc:
title: data.files[0].name
async: false
success: (data) ->
form.find("input[name=key]").val data.key
form.find("input[name=policy]").val data.policy
form.find("input[name=signature]").val data.signature
data.submit()
send: (e, data) ->
$(".progress, #dropzone").fadeIn()
$.each data.files, (index, file) ->
$('.well').html("").append("Uploading: " + file.name + '<br>' …
Run Code Online (Sandbox Code Playgroud) 我遇到麻烦让capistrano capify .
命令工作.我已经成功安装了gem(手动尝试并通过gemfile查看它是否有用),因为它出现了,我使用的是RVM和mac osx 10.8.4.
这个问题点的所有记录的问题似乎都是路径问题,因为我的etc/paths
文件似乎与结果非常不同echo $PATH
似乎是准确的.但是,我不确定要纠正什么以及添加什么来使事情发挥作用.
如何更改设置并获取capify.命令工作?
以下是我的环境信息.如果有人需要更多的代码只是喊.
sudo nano etc/paths
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
Run Code Online (Sandbox Code Playgroud)
的结果 echo $PATH
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/bin:/Users/andrew/.rvm/gems/ruby-1.9.3-p448@global/bin:/Users/andrew/.rvm/rubies/ruby-1.9.3-p448/bin:/Users/andrew/.rvm/bin:/Applications/Postgres.app/Contents/MacOS/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/andrew/.rvm/bin:/home/user/.gem/ruby/1.8
Run Code Online (Sandbox Code Playgroud)
捆绑安装
Using capistrano (3.0.0)
Run Code Online (Sandbox Code Playgroud)
捆绑显示capistrano
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0
Run Code Online (Sandbox Code Playgroud)
与bundle exec一起运行
bundle exec capify .
bundler: command not found: capify
Install missing gem executables with `bundle install`
Run Code Online (Sandbox Code Playgroud) 我有一个rails应用程序,使用他们的CORS配置将视频上传到AWS S3存储桶,当完成此操作并创建rails视频对象时,会创建Elastic Transcoder作业以将视频编码为.mp4格式并生成缩略图图像,AWS SNS可以在作业完成时发送推送通知.
这个过程都运行良好,我在上传完成时收到SNS通知,但是我可以获取视频网址,但通知只包含缩略图模式而不是实际文件名.
以下是我从AWS SNS收到的典型通知.NB.这是来自输出哈希
{"id"=>"1", "presetId"=>"1351620000001-000040", "key"=>"uploads/video/150/557874e9-4c67-40f0-8f98-8c59506647e5/IMG_0587.mp4", "thumbnailPattern"=>"uploads/video/150/557874e9-4c67-40f0-8f98-8c59506647e5/{count}IMG_0587", "rotate"=>"auto", "status"=>"Complete", "statusDetail"=>"The transcoding job is completed.", "duration"=>10, "width"=>202, "height"=>360}
Run Code Online (Sandbox Code Playgroud)
正如您在thumbnailPattern下看到的那样,只是要使用的文件模式,而不是创建的实际文件.
有谁知道我如何获得通过弹性转码器和SNS创建的文件的URLS?
transcoder.rb#=>我在保存视频时创建了一个新的转码器对象
class Transcoder < Video
def initialize(video)
@video = video
@directory = "uploads/video/#{@video.id}/#{SecureRandom.uuid}/"
@filename = File.basename(@video.file, File.extname(@video.file))
end
def create
transcoder = AWS::ElasticTranscoder::Client.new(region: "us-east-1")
options = {
pipeline_id: CONFIG[:aws_pipeline_id],
input: {
key: @video.file.split("/")[3..-1].join("/"), # slice off the amazon.com bit
frame_rate: "auto",
resolution: 'auto',
aspect_ratio: 'auto',
interlaced: 'auto',
container: 'auto'
},
outputs: [
{
key: "#{@filename}.mp4",
preset_id: '1351620000001-000040', …
Run Code Online (Sandbox Code Playgroud) video ruby-on-rails amazon-s3 amazon-web-services amazon-sns
我有一个任务,我需要在Rails 3.2中上传一个文件(.txt),而不使用任何外部宝石来完成腿部工作(我担心不可协商)该文件也需要保存到数据库中.我有以下代码,但是当我尝试使用表单上传/创建新附件时,它会返回错误;
No route matches [POST] "/attachments/create"
Run Code Online (Sandbox Code Playgroud)
看起来不像使用模型中的uploaded_file调用create动作,但我不确定如何纠正它.如果有人能指出我正确的方向,我将不胜感激.
所以我的代码如下;
AttachmentsController.rb
class AttachmentsController < ApplicationController
def show
@attachment = Attachment.find(params[:id])
end_data @attachment.data, :filename => @attachment.filename, :type => @attachment.content_type
end
def create
return if params[:attachment].blank?
@attachment = Attachment.new
@attachment.uploaded_file = params[:attachment]
if @attachment.save
flash[:notice] = "Thank you for your submission..."
redirect_to root_path
else
flash[:error] = "There was a problem submitting your attachment."
render "new"
end
end
end
Run Code Online (Sandbox Code Playgroud)
Attachment.rb
class Attachment < ActiveRecord::Base
def uploaded_file=(incoming_file)
self.filename = incoming_file.original_filename
self.content_type = incoming_file.content_type
self.data = …
Run Code Online (Sandbox Code Playgroud) 是否可以将算术运算符(*,+, - ,/)作为参数传递给ruby方法?我已经看到这在C++中执行.轨道能够类似吗?
def calculate(operator)
1254 operator 34
end
puts calculate(+)
Run Code Online (Sandbox Code Playgroud) 下午所有,
我正在尝试编写一个脚本,通过其<img src=""/>
标签从文章中提取第一个图像.所以如果一篇文章有:
<p>Lorem ipsum dolor sit amet, labore et dolore magna aliqua.<img src="example.jpg"/> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
Run Code Online (Sandbox Code Playgroud)
我想提取整个图像标签, <img src="example.jpg"/>.
我发现这个正则表达式只提取图像的位置:
content_to_extract_from[/img.*?src="(.*?)"/i,1]
Run Code Online (Sandbox Code Playgroud)
生产,"example.jpg".
有没有人知道将捕获标签的正则表达式?
提前谢谢,安迪
晚上好,
过去几个小时,我坐在这里摸不着头脑.
我有一个非常简单的评论模型附加到文章模型.问题是,每篇文章评论部分的末尾似乎都有一个空白的评论.如果我尝试使用像"大写nil类"那样大写错误的方法,如果我将评论放在每个评论(Facebook样式)的灰色背景的div中,文章末尾会出现一个空白框评论.有谁知道发生了什么?
无论如何继承人代码:评论控制器
def create
@article = Article.find(params[:article_id])
@comment = @article.comments.create(params[:comment])
if @comment.save
flash[:success] = "Comment created"
redirect_to @article
else
flash[:error] = "Something went wrong"
redirect_to @article
end
end
def destroy
@article = Article.find(params[:article_id])
@comment = @article.comments.find(params[:id])
@comment.destroy
redirect_to @article
end
end
Run Code Online (Sandbox Code Playgroud)
评论模型
attr_accessible :name, :content
belongs_to :article
validates_presence_of :article_id
validates_presence_of :content, length: { maximum: 300 }
default_scope order: "comments.created_at DESC"
Run Code Online (Sandbox Code Playgroud)
评论表
<a href='#', id='comments-form', class="btn btn-large">Add a comment</a>
<div id="comment">
<%= form_for([@article, @article.comments.build]) do |f| %>
<%= f.label …
Run Code Online (Sandbox Code Playgroud) 所以我得到了非常常见的ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
mysql 错误。我已经尝试了论坛上的所有典型修复,通过 mysql_safe 方法登录,然后尝试重置我的 root 密码。但是,这样做时它会返回;
UPDATE user SET password=PASSWORD("PASSWORD")WHERE user="root";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
Run Code Online (Sandbox Code Playgroud)
因此,由于没有行受到影响,我认为没有用户可以实际更改。我试图创建一个用户:
CREATE USER 'root'@'localhost' IDENTIFIED BY 'root'
-> GRANT ALL ON *.* TO 'root'@'localhost'
-> flush privileges;
However this returns with ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for …
Run Code Online (Sandbox Code Playgroud) ruby ×5
amazon-s3 ×2
capistrano ×2
javascript ×2
jquery ×2
rubygems ×2
amazon-sns ×1
associations ×1
bash ×1
coffeescript ×1
comments ×1
ember-data ×1
ember.js ×1
file-upload ×1
html ×1
image ×1
mysql ×1
path ×1
permissions ×1
regex ×1
video ×1