Resque web interface loading error - ruby-on-rails-3

I have installed Resque in Rails 3 using this tutorial.
The problem is when I'm trying to use the Resque web interface. When I go to {localhost}/resque/ , the browser is getting redirected to {localhost}/resque/resque/overview/true/false which essentially does not exist.
However {localhost}/resque/overview seems to open up the correct interface, although has broken links. (Like clicking on stats again redirects me to {localhost}/resque/resque/stats/resque/true/false, which is again non-existant)
Here is my config.ru file:
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require 'resque/server'
require 'logger'
# Set the AUTH env variable to your basic auth password to protect Resque.
AUTH_PASSWORD = 'secret'
if AUTH_PASSWORD
Resque::Server.use Rack::Auth::Basic do |username, password|
password == AUTH_PASSWORD
end
end
run Rack::URLMap.new \
"/" => Marina::Application,
"/resque" => Resque::Server.new

It seems that it's a problem with Sinatra version 1.2.0. Using Sinatra 1.1.3 works fine. Details on this Resque open issue: https://github.com/defunkt/resque/issues#issue/221
From the issue description:
When I go to "/resque" route it
redirects to
"/resque/resque/overview/true/false"
and fail with 404 Sinatra error page.
Add sinatra 1.1.3 to Gemfile, run
"bundle update sinatra" and voila:
http://cl.ly/460d0C0x2N1W2D333j1f
As I'm new to Ruby and don't know yet what is a Gemfile :), I forced the installation of Sinatra 1.1.3 and it worked like a charm:
$ gem uninstall sinatra
$ gem install sinatra -v 1.1.3
Regards,
Deluan.

Related

Capistrano "no such file or directory - git ls-remote git#github.com"

I built a rails app and i am currently in the process of deploying it from my windows system to vexxhost (a hosting company). I have a repository on github and i have followed all the procedures of deploying my rails app. Everything was going fine until i typed "cap deploy:cold",after which the following error was Displayed.
My deploy.rb file
require 'bundler/capistrano'
require 'capistrano'
require 'capistrano-vexxhost'
# Account Settings
ssh_options[:forward_agent] = true
set :user, "innocent"
set :password, "2Q0bNx85it"
set :domain, "legoads.com"
set :mount_path,"/home/innocent/public_html"
set :application,"legoads"
set :scm, :git
set :repository, "git#github.com:innoc/Legoads.git"
default_run_options[:pty] = true
From the error it appears that git isn't installed in the remote server. Install git and try again, or better, make a capistrano recipe to setup your server, which will among other tasks install git.

How can I get rails to use pg by default?

It's not a huge burden but I would really like to be able to change the default gem-set on my rails apps when I create them so that they're ready for Heroku.
What is the best way to go about doing this?
You can specify the database with -d when running rails new:
Usage:
rails new APP_PATH [options]
Options:
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
Description:
You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.
So for PostgreSQL this is:
rails new myapp -d postgresql
To make this the default put -d postgresql into ~/.railsrc
Another option is to change gem 'sqlite3' to gem 'pg' in your Gemfile as suggested in Getting Started with Rails 3.x on Heroku.

apn_sender gem daemon not running

Im using apn_sender for rails 3 and i have been able to install the gem and get it working just fine by using
rake apn:sender
I have tried to get it started in production mode on a ubuntu box by starting the daemon and it does not seem to work. When i type
script/apn_sender --environment=production --verbose start
I dont see anything. No log present.
when i try to type
script/apn_sender status
It returns with
apn_sender: no instances running
Just trying to understand why it is not running.
i just solved this problem. Try to create a file called 'script' in generators/apn_sender/templates . .
Put this in your script file
# !/usr/bin/env ruby
# Daemons sets pwd to /, so we have to explicitly set RAILS_ROOT
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
require 'rubygems'
require 'apn'
require 'apn/sender_daemon'
APN::SenderDaemon.new(ARGV).daemonize
bash 'rails g apn_sender' in your terminal and will create 'script/apn_server' with same content as above
After that bash this code
./script/apn_server --environment=production --verbose start
it will create log/apn_sender.log . Try running
APN.notify('token',{:alert => '#' , :badge => 1})
or else in rails c to confirm if it works or not , and of course
rake apn:sender
Hope it will help :)
EDIT
You have to install redis and configure

Refinery error when pushing to Heroku

I've a Refinery app, works great locally.
Created a bamboo stack on Heroku.
When I try to push I can see this:
Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Then I open it up in browser:
"We're sorry, but something went wrong."
$ heroku logs
Rendered vendor/bundle/ruby/1.9.1/gems/refinerycms-authentication-2.0.2/app/views/refinery/users/new.html.erb within refinery/layouts/login (82.3ms)
2012-03-15T14:43:25+00:00 app[web.1]: Completed 500 Internal Server Error in 1269ms
full output is here
Any help is great, thanks!
+++
Update:
Updated the stack to Cedar and made Ruby env 1.9.3
$ heroku config
DATABASE_URL => ..
GEM_PATH => vendor/bundle/ruby/1.9.1
LANG => en_US.UTF-8
PATH => bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
RACK_ENV => production
RAILS_ENV => production
RUBY_VERSION => ruby-1.9.3-p0
SHARED_DATABASE_URL => ..
$ heroku info --app mimacohuoncedar
=== mimacohuoncedar
Addons: Basic Logging, Shared Database 5MB
Database Size: (empty)
Git URL: git#heroku.com:mimacohuoncedar.git
Owner: ..
Repo Size: 9M
Slug Size: 19M
Stack: cedar
Web URL: http://mimacohuoncedar.herokuapp.com/
$ heroku logs now shows this:
this-updated
Where to go on? Thanks
Dont know if you managed to fix this but I ran into the same issue using the Cedar stack. Found this article on Heroku that seemed to do the trick for me. Ran the line in terminal and it pushed first time.
I am seeing this same error, and the accepted answer did not solve it for me;
This blog however, did the trick. The blog title refers to Rails 3.2, but I'm on 3.1 and was seeing this same error.
The blog recommended adding this line to application.rb.
config.assets.initialize_on_precompile = false
The meaning, as summarized from the article;
This option prevents the Rails environment from being loaded when the assets:precompile task is executed. Because Heroku precompiles assets before setting the database configuration, you need to set this configuration to false or you Rails application will try to connect to an unexisting database.
Added the line and pushed, everything seems good now.
That output looks suspiciously like Cedar stack and not Bamboo - give http://devcenter.heroku.com/articles/labs-user-env-compile a go. That should sort you out.

RHEL Ruby (1.9.2) on Rails (3.0.9) and Passenger (3.0.7) Application could not be started

I'v been banging my head for a day with Passenger installation in order to start to serve Ruby on Rails on my RHEL server.
I have Ruby (1.9.2) on Rails (3.0.9) and Passenger (3.0.7) installed with RVM.
Apache configuration:
RailsBaseURI /dev/testpublic
#RackBaseURI /dev
<Directory /var/www/dev/testublic>
Options -MultiViews
</Directory>
I generated the testproject with
rails new . -d mysql
rails generate scaffold Post name:string title:string content:text
rake db:migrate
Then navigating to the test project i get:
A source file that the application requires, is missing.
It is possible that you didn't upload your application files
correctly. Please check whether all your application files are
uploaded.
A required library may not installed. Please install all libraries
that this application requires.
Further information about the error may have been written to the
application's log file. Please check it in order to analyse the
problem.
Error message:
no such file to load -- rubygems/path_support Exception class:
LoadError Application root:
/www/dev/rubytest
Any help or tips would be of help. Thank you!
RR -
And to answer my own question. This is now solved.
I noticed that my installation of RVM did not complete it self as it should have. There was few read blocks and a missing profile configuration. Here is what I did to fix it:
My RVM was installed as multi-user, so that is why there were issues.
chmod a+rx /usr/local/rvm/ -R
chmod a+r /etc/rvmrc
And to /etc/profile and to my own .basch_profile
[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm" # This loads RVM into a shell session.
After this i got a different problem - now passeger was looking for the app on the wrong directory. I have my apache set so that I have all top level directories set as separate files and I can enable / disable like sites-enabled is done.
DocumetRoot on Apache configuration (httpd.conf) was set but pointing towards a subdirectory that is on a different path than where rails app was.
Document root was
DocumentRoot "/var/www/default"
Where as my rails app was located in
/var/www/dev/testpublic
This resulted in passenger looking for the app on directory
/var/www/default/dev/testpublic
After modifying the confic accordingly and tweking my setup so that I could set the DocumetRoot to /var/www/ it started to work.
Hope this helps if someone else runs into similar issue.
RR