我在Apache上使用Passenger生产了一个Rails 3应用程序.我有这个代码:
class Billing < ActiveRecord::Base
after_save :sendEmails
private
def sendEmails
fork do
UserMailer.clientBilling(self.user, self).deliver
end
end
end
Run Code Online (Sandbox Code Playgroud)
在localhost中,当应用程序创建帐单时,在保存后,应用程序会向用户发送电子邮件,一切正常.但是在服务器中,在应用程序创建计费之后,它会抛出与gem2M2相关的错误,"MySQL服务器已经消失"或"连接丢失"等错误,并且应用程序不会发送电子邮件.如果我删除fork它工作正常,但我想使用fork,我想创建一个单独的进程,因为它在发送电子邮件时需要很长时间.可能是什么问题呢?
我使用Ruby 1.9.3p0,Rails 3.1.2与Apache和Passenger in Production.当我尝试创建一个远程函数时,它会抛出这个错误:
ActionView::MissingTemplate (Missing template video/loadVideo, application/loadVideo with
{:handlers=>[:erb, :builder], :formats=>[:js, "application/ecmascript", "application/x-
ecmascript", :html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml,
:multipart_form, :url_encoded_form, :json], :locale=>[:en, :en]}. Searched in
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,没有处理程序:coffee,这就是为什么不处理文件video/loadVideo.js.coffee的原因 ; 我运行命令rake assets:precompile但没有任何变化.
Gemfile源'http://rubygems.org'
gem 'rails', '3.1.2'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'will_paginate', '~> 3.0'
gem "bcrypt-ruby", :require => "bcrypt"
gem 'mysql'
#Problems in Debian, the error was:
#Could not find a JavaScript …Run Code Online (Sandbox Code Playgroud) 我想在Rails 3.2.9中使用omniauth-facebook登录Facebook; 我已经按照http://railscasts.com/episodes/360-facebook-authentication中的Ryan Bates的步骤进行操作,在这一刻我有相同的代码.
如果我尝试登录没有Javascript它可以工作(我需要Facebook,我授予权限,并让我成功回到应用程序),但如果我尝试使用Javascript(对于Facebook弹出窗口)它最初显示弹出窗口登录,但然后进行重定向并抛出此错误(不要求权限):
Started GET "/auth/facebook/callback" for 127.0.0.1 at 2012-11-16 15:16:03 -0600
(facebook) Callback phase initiated.
(facebook) Authentication failure! invalid_credentials: OmniAuth::Strategies::OAuth2::CallbackError, OmniAuth::Strategies::OAuth2::CallbackError
OmniAuth::Strategies::OAuth2::CallbackError (OmniAuth::Strategies::OAuth2::CallbackError)
Run Code Online (Sandbox Code Playgroud)
这是一个非常常见的错误; 我做了研究并尝试了所有的解决方案(大多数是几个月前),但都没有.这是我尝试过的:
http://localhost:3000/omniauth-facebook must pass either a代码parameter or a signed request (viasigned_request parameter or afbsr_XXXcookie)我还该怎么办?(我认为关键在于Javascript,现在我有了相同的视频代码,使用CoffeeScript).提前致谢!
我正在尝试制作一个"通用模型",以便它可以连接到任何数据库的任何表.首先,我创建了这个连接到另一个指定数据库的类(不使用模式)
D b
class Db < ActiveRecord::Base
self.abstract_class = true
attr_accessor :error
def initialize(item = nil)
@error = ""
connect
super
end
def connect
could_connect = true
@error = ""
begin
ActiveRecord::Base.establish_connection(
:adapter => "mysql2",
:host => "localhost",
:username => "root",
:password => "",
:database => "another_database",
:port => 3306,
:encoding => "utf8"
)
rescue ActiveRecord::ConnectionNotEstablished
@error = "Could not connect to database. The connection was not established"
could_connect = false
rescue Mysql2::Error
@error = "Could not connect to database …Run Code Online (Sandbox Code Playgroud) 我正试图在3.2.8上使用我的Rails应用程序上的Captainrano上的gem,使用RVM和Rails版本的gemset.
我收到以下错误:无法在任何源中找到rake-10.0.3(Bundler :: GemNotFound)
这是错误的输出(我记录在文件上):
/home/some_user/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/spec_set.rb:90:in `block in materialize': Could not find rake-10.0.3 in any of the sources (Bundler::GemNotFound)
from /home/some_user/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/spec_set.rb:83:in `map!'
from /home/some_user/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/spec_set.rb:83:in `materialize'
from /home/some_user/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/definition.rb:113:in `specs'
from /home/some_user/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/definition.rb:158:in `specs_for'
from /home/some_user/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/definition.rb:147:in `requested_specs'
from /home/some_user/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/environment.rb:23:in `requested_specs'
from /home/some_user/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:11:in `setup'
from /home/some_user/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler.rb:116:in `setup'
from /home/some_user/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/setup.rb:17:in `<top (required)>'
from /home/some_user/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
from /home/some_user/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
from /home/some_user/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /home/some_user/some_user/config/boot.rb:6:in `<top (required)>'
from /home/some_user/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/some_user/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/rails:5:in `<main>'
Run Code Online (Sandbox Code Playgroud)
当我使用Rake 10.0.2时,我也得到了错误(我进行了捆绑更新并获得了Rake 10.0.3,我将其留待测试).此外,我注意到捆绑器正在搜索@global,我认为它应该搜索gemset(称为@ r328,位于/home/some_user/.rvm/gems).
.rvmrc(位于项目内部)
source …Run Code Online (Sandbox Code Playgroud) 我正在按照这个片段在Capistrano中添加Sunspot Solr https://gist.github.com/doitian/1795439并且它有效,但是当我运行cap solr:reindex它显示一个问题(如预期的那样)询问我是否要删除所有索引,所以我回答"是",但终端似乎在等待响应.
这是reindex的代码:
desc "reindex the whole database"
task :reindex, :roles => :app do
stop
run "rm -rf #{shared_path}/solr/data"
start
run "cd #{current_path} && #{rake} RAILS_ENV=#{rails_env} sunspot:solr:reindex"
end
Run Code Online (Sandbox Code Playgroud)
这是消息:
* executing "cd /home/user/rapps/app/current && bundle exec rake RAILS_ENV=production sunspot:solr:reindex"
servers: ["9.9.9.9"]
[9.9.9.9] executing command
** [out :: 9.9.9.9] *Note: the reindex task will remove your current indexes and start from scratch.
** [out :: 9.9.9.9] If you have a large dataset, reindexing can take a very long …Run Code Online (Sandbox Code Playgroud) capistrano ruby-on-rails sunspot sunspot-solr rvm-capistrano
我在Perl中有一个使用system 命令创建另一个进程的进程,我将它留在内存中并传递一些这样的变量:
my $var1 = "Hello";
my $var1 = "World";
system "./another_process.pl $var1 $var2 &";
但系统命令只返回结果,我需要获取PID.我想做一些像fork的东西.我该怎么办?我怎么能用不同的脚本制作像fork这样的东西?
提前致谢!
capistrano ×2
fork ×2
ruby ×2
activerecord ×1
bundler ×1
coffeescript ×1
facebook ×1
mysql ×1
mysql2 ×1
oauth-2.0 ×1
omniauth ×1
passenger ×1
perl ×1
process ×1
rake ×1
sunspot ×1
sunspot-solr ×1
system ×1
whenever ×1