Refinery error when pushing to Heroku - ruby-on-rails-3

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.

Related

webrick server not running on ruby version 5.0.7.2 on CLOUD9 IDE on AWS

I got into the app directory inside the blog folder
and ran a command to start the WEBRick server:
rails server -b $IP -p $PORT
CODE CONSOLE IMAGE
Above is the link for the image of my console.
Please HELP
It could be that the puma server that you currently have loading will work out fine anyway.

$ rails server... undefined method `gem' for main:Object (NoMethodError)

I'm new to Rails trying to complete this tutorial, but I can;t even get started.
http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec-rails_server
I am at Step 1.2.5
I am supposed to start the server using: $ rails server
I'm getting this error whenever I try to run any rails command.
localhost:first_app home$ rails server
/usr/bin/rails:22: undefined method `gem' for main:Object (NoMethodError)
Running rails commands used to work, because I had completed other tutorials from other books in the past. However, somewhere along the steps in this tutorial something was messed up.
Is it possible that editing my bash_profile caused this?
My bash_profile looks like this now:
export PATH=/bin:/usr/bin:"$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
I added this line to it: export PATH=/bin:/usr/bin:"$PATH" after following directions in step Listing 1.1. Creating a gem configuration file.
I'm not sure if this helps, but If I type:
$ which rails
I get:
/Users/home/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/bin/rails
Have you installed gem? type:
which gem
and see what you get. If you don't have gem or the wrong version, follow these instructions: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec-install_rubygems
typing
$ rvm use 1.9.3#rails3tutorial2ndEd --create --default.
allowed me to continue.
I had a similar problem under ubuntu. I fixed it by changing gnome-terminal settings https://rvm.io/integration/gnome-terminal

thinking sphinx error when rake thinking_sphinx:start

I am using gem 'thinking-sphinx', '2.0.10' for search functionality.I am following http://railscasts.com/episodes/120-thinking-sphinx tutorial for this.
script/plugin install git://github.com/freelancing-god/thinking-sphinx.git
rake thinking_sphinx:index
These 2 steps executed without any problem,but when i did rake thinking_sphinx:start it was giving following error :
Failed to start searchd daemon. Check /home/user/newsvn/alumnicell/log/searchd.log.
Failed to start searchd daemon. Check /home/user/newsvn/alumnicell/log/searchd.log
I searched on net about this but even trying many solutions i am not able to solve this error.Also while checking on net i came to know that there should be sphinx.yml file in config which is not present in my project.
How to solve this error?
solved it...
i just added sphinx.yml file inside config and specified port number for each environment as follows:
development:
port: 9310
morphology: stem_en
test:
port: 9310
morphology: stem_en
production:
port: 9310
morphology: stem_en
then changed listen address in development.sphinx.conf for searchd as follows:
searchd
{
listen = 127.0.0.1:9310
}
then on console ran command:
rake thinking_sphinx:rebuild
May be /home/user/newsvn/alumnicell/log/searchd.log has solution for the problem.
Just post it!

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

Rails 3 / whenever cron not firing

I am using whenever to fire a rake task every 5 minutes for my app.
schedule.rb:
every 5.minutes do
rake "audit",
:environment => 'development'
end
"whenever" in console:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /Users/john/Sites/rambler && RAILS_ENV=development bundle exec rake audit --silent'
"rake audit" in console works properly.
So all looks good .... except it doesn't work. Nothing happens every five minutes.
Is this because I am trying to run it in development / local?
Thanks!
You need to update your cron file every time you change it.
After you have addded your cron job do this:
whenever --update-crontab 'project_name'
Also I only found whenever working fine in production mode only.
UPDATE:
I have found that we can use whenever in development mode also. Just add
set :environment, "development"
set :output, {:error => "log/error.log", :standard => "log/cron.log"}
to your scehdule.rb file. ( The log one is optional but still you can use that for testing purpose)
Finally I have solved how to run the gem Whenever. It's working good on production, but not in development mode (I think that to working good in dev mode you must do some tricks).
see this answer for working in dev mode: Cron not working in Whenever gem
Then, these are the processes to do:
install the gem
write your scheduler.rb file
push to the remote server
login to the remote server (for example with ssh)
see if whenever is good uploaded by running in terminal: whenever
update whenever crontab by running: whenever --update-crontab
restart the server crontab (for example in ubuntu): sudo service cron restart
check if crontab are good implemented on the server: crontab -l
That is!