Gareth Gomersall

Joined

320 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Ruby issue when doing cap deploy production

Hey James, that's awesome!

I've also setup the a record now so it's accessible via nibliapp.com

Thanks for all the help from you and Chris

Cheers
Gareth

Posted in Ruby issue when doing cap deploy production

awesome! thanks James, emailing you now....

Posted in Ruby issue when doing cap deploy production

Yeah sure i don't mind giving you access to the production server...
Do you want the deploy account or would you like me to setup a new user with sudo access?

Also do you want me to post those details direct on this thread?

Posted in Ruby issue when doing cap deploy production

Hi James,

Thanks mate... apologies i turned it private, but i've made it public again... same link

Cheers

Posted in Ruby issue when doing cap deploy production

ok so i've retraced all my steps in the documents for setting up this VPS on digitalocean i couple of things i changed (not sure if it had anything to do with the cap production deploy - but they are as follows -

  • config/deploy/production.rb - i added the db part

set :stage, :production
server '46.101.34.7', user: 'deploy', roles: %w{web app db}

  • Capfile - i added the rails/assets and rails/migrations

require 'capistrano/rvm'
set :rvm_type, :user
set :rvm_ruby_version, '2.1.2-p95'

require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

I've managed to get the site up... on http://46.101.34.7, but now it seems when i fill out my form it takes me to a 404 error

i've checked the production logs and it's showing this -
I, [2015-04-03T11:56:52.639873 #30093] INFO -- : Migrating to CreateLeads (20150327183722)
I, [2015-04-03T11:56:52.696744 #30093] INFO -- : Migrating to CreateActiveAdminComments (20150330091152)
I, [2015-04-03T12:05:28.394905 #31343] INFO -- : Started GET "/" for 81.138.164.169 at 2015-04-03 12:05:28 -0400
I, [2015-04-03T12:05:28.430379 #31343] INFO -- : Processing by PagesController#index as HTML
I, [2015-04-03T12:05:28.519323 #31343] INFO -- : Rendered layouts/_leadsform.html.erb (59.3ms)
I, [2015-04-03T12:05:28.519556 #31343] INFO -- : Rendered pages/index.html.erb within layouts/application (62.4ms)
I, [2015-04-03T12:05:28.522403 #31343] INFO -- : Rendered layouts/_header.html.erb (0.4ms)
I, [2015-04-03T12:05:28.523556 #31343] INFO -- : Rendered layouts/_footer.html.erb (0.3ms)
I, [2015-04-03T12:05:28.524008 #31343] INFO -- : Completed 200 OK in 93ms (Views: 71.2ms | ActiveRecord: 10.7ms)
I, [2015-04-03T12:09:18.540633 #31343] INFO -- : Started GET "/" for 81.138.164.169 at 2015-04-03 12:09:18 -0400
I, [2015-04-03T12:09:18.549313 #31343] INFO -- : Processing by PagesController#index as HTML
I, [2015-04-03T12:09:18.620812 #31343] INFO -- : Rendered layouts/_leadsform.html.erb (61.1ms)
I, [2015-04-03T12:09:18.621050 #31343] INFO -- : Rendered pages/index.html.erb within layouts/application (65.1ms)
I, [2015-04-03T12:09:18.623674 #31343] INFO -- : Rendered layouts/_header.html.erb (0.5ms)
I, [2015-04-03T12:09:18.625089 #31343] INFO -- : Rendered layouts/_footer.html.erb (0.5ms)
I, [2015-04-03T12:09:18.625501 #31343] INFO -- : Completed 200 OK in 76ms (Views: 72.1ms | ActiveRecord: 0.0ms)

i've checked my app on local machine and works fine and redirects to root_path when completing the form, but on the server it tries to redirect to /leads
i've check code matches on both aswell and all seems legit.... strange... maybe James or Chris you know why this is?

Cheers
Gareth

Posted in Ruby issue when doing cap deploy production

Hey again James,

Well i did what was recommended, dropped the database (i even recreated the db user), recreated the db and then granted the access to the db user.... ran the command from my local machine - cap production deploy:migrate

No joy!

checked my production.log in the following locations /appname/current/log and /appname/shared/log but nothing printed in those.

my /var//var/log/nginx/error.log produces this -

App 10656 stdout: Completed 500 Internal Server Error in 2ms
App 10656 stdout:
App 10656 stdout: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "leads" does not exist
App 10656 stdout: LINE 5: WHERE a.attrelid = '"leads"'::regclass
App 10656 stdout: ^
App 10656 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 10656 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 10656 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 10656 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 10656 stdout: WHERE a.attrelid = '"leads"'::regclass
App 10656 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 10656 stdout: ORDER BY a.attnum
App 10656 stdout: ):
App 10656 stdout: app/controllers/pages_controller.rb:4:in index'
App 10656 stdout:
App 10656 stdout:
App 10656 stdout:
App 10656 stdout: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "leads" does not exist
App 10656 stdout: LINE 5: WHERE a.attrelid = '"leads"'::regclass
App 10656 stdout: ^
App 10656 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 10656 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 10656 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 10656 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 10656 stdout: WHERE a.attrelid = '"leads"'::regclass
App 10656 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 10656 stdout: ORDER BY a.attnum
App 10656 stdout: ):
App 10656 stdout: app/controllers/pages_controller.rb:4:in
index'
App 10656 stdout:
App 10656 stdout:

I don't want to give up (quitting is for quitters), but it seems as though heroku is a much easier option (for a newbie, but i don't want to be a newbie forever!)... so any help is much appreciated

Posted in Ruby issue when doing cap deploy production

Hey James,
ok so just to clarify, i'm going to drop the database (nibli_leads), recreate it manually, and assign it to the db user...

when i'm recreating the database, do i have to manually create the table as well? i.e. table called "leads", with -
t.string "name"
t.string "email"
t.string "device"
t.string "country"
t.datetime "created_at"
t.datetime "updated_at"

and then run cap deploy:migrate?
or just create the database, without the table of "leads" and run cap deploy:migrate on my local machine?

Posted in Ruby issue when doing cap deploy production

Well i tried running cap deploy:migrations on my local machine and server (not sure which is the correct one to run it on)

my server produced this -
WARNING:root:could not open file '/etc/apt/sources.list.d/passenger.list'

The program 'cap' is currently not installed. You can install it by typing:
sudo apt-get install capistrano

my local machine produced this -
Stage not set, please call something such as cap production deploy, where production is a stage you have defined.

so i ran it as cap production deploy:migrate -- and got this -
DEBUG [c6d7d298] Running /usr/bin/env [ -d ~/.rvm ] as deploy@46.101.34.7
DEBUG [c6d7d298] Command: [ -d ~/.rvm ]
DEBUG [c6d7d298] Finished in 1.270 seconds with exit status 0 (successful).
DEBUG [9ad5298d] Running ~/.rvm/bin/rvm version as deploy@46.101.34.7
DEBUG [9ad5298d] Command: ~/.rvm/bin/rvm version
DEBUG [9ad5298d] rvm 1.26.11 (latest) by Wayne E. Seguin wayneeseguin@gmail.com, Michal Papis mpapis@gmail.com [https://rvm.io/]
DEBUG [9ad5298d] Finished in 0.279 seconds with exit status 0 (successful).
rvm 1.26.11 (latest) by Wayne E. Seguin wayneeseguin@gmail.com, Michal Papis mpapis@gmail.com [https://rvm.io/]
DEBUG [dc47bb01] Running ~/.rvm/bin/rvm current as deploy@46.101.34.7
DEBUG [dc47bb01] Command: ~/.rvm/bin/rvm current
DEBUG [dc47bb01] ruby-2.1.2
DEBUG [dc47bb01] Finished in 0.275 seconds with exit status 0 (successful).
ruby-2.1.2
DEBUG [a69e5613] Running ~/.rvm/bin/rvm default do ruby --version as deploy@46.101.34.7
DEBUG [a69e5613] Command: ~/.rvm/bin/rvm default do ruby --version
DEBUG [a69e5613] ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
DEBUG [a69e5613] Finished in 0.633 seconds with exit status 0 (successful).
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

this is my git repo - https://github.com/ggomersall/Nibli_leads

Posted in Ruby issue when doing cap deploy production

James this is the latest log - (it was working a moment ago, but my form didn't work - i got a 404 error when i submitted it, so i deleted the table)

pp 5028 stdout: Completed 500 Internal Server Error in 7ms
App 5028 stdout:
App 5028 stdout: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "leads" does not exist
App 5028 stdout: LINE 5: WHERE a.attrelid = '"leads"'::regclass
App 5028 stdout: ^
App 5028 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 5028 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 5028 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 5028 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 5028 stdout: WHERE a.attrelid = '"leads"'::regclass
App 5028 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 5028 stdout: ORDER BY a.attnum
App 5028 stdout: ):
App 5028 stdout: app/controllers/pages_controller.rb:4:in index'
App 5028 stdout:
App 5028 stdout:
App 5028 stdout:
App 5028 stdout: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "leads" does not exist
App 5028 stdout: LINE 5: WHERE a.attrelid = '"leads"'::regclass
App 5028 stdout: ^
App 5028 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 5028 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 5028 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 5028 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 5028 stdout: WHERE a.attrelid = '"leads"'::regclass
App 5028 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 5028 stdout: ORDER BY a.attnum
App 5028 stdout: ):
App 5028 stdout: app/controllers/pages_controller.rb:4:in
index'
App 5028 stdout:
App 5028 stdout:

Posted in Ruby issue when doing cap deploy production

So Chris where do i run the cap deploy:migrate? on my local machine or on the server?

when run on the server

WARNING:root:could not open file '/etc/apt/sources.list.d/passenger.list'

The program 'cap' is currently not installed. You can install it by typing:
sudo apt-get install capistrano

Posted in Ruby issue when doing cap deploy production

i spoke too soon, my form isn't working! :(

Posted in Ruby issue when doing cap deploy production

I GOT IT WORKING!!!!! haha
sorry for all the spam in this forum post over the last couple of days....

I figured out how to create the table leads and the site is working a treat! (fingers crossed)

check it out - http://46.101.34.7

Posted in Ruby issue when doing cap deploy production

Hey Guys.....

I've still got this dastardly "We're sorry, but something went wrong." error with my nibli site (chris you'll remember doing the code cast for me:) )
I've check the production.log under app/current/log but nothing there, i've also checked the /var/log/nginx/error.log and it's got something to do with the table lead (i'm guessing

App 2163 stdout: Processing by PagesController#index as HTML
App 2163 stdout: PG::UndefinedTable: ERROR: relation "leads" does not exist
App 2163 stdout: LINE 5: WHERE a.attrelid = '"leads"'::regclass
App 2163 stdout: ^
App 2163 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 2163 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 2163 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 2163 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 2163 stdout: WHERE a.attrelid = '"leads"'::regclass
App 2163 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 2163 stdout: ORDER BY a.attnum
App 2163 stdout:
App 2163 stdout: PG::UndefinedTable: ERROR: relation "leads" does not exist
App 2163 stdout: LINE 5: WHERE a.attrelid = '"leads"'::regclass
App 2163 stdout: ^
App 2163 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 2163 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 2163 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 2163 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 2163 stdout: WHERE a.attrelid = '"leads"'::regales
App 2163 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 2163 stdout: ORDER BY a.attnum
App 2163 stdout:
App 2163 stdout: Completed 500 Internal Server Error in 2ms

I thought that when we do the created the database it would do all the tables, how do i create them? do i have to do rake db:migrate?

Posted in Ruby issue when doing cap deploy production

ok so i've edited the secrets.yml file from -

production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
to
production:
secret_key_base: 1fa75cf22906eaa8bc9a9ebd43dfa80731morestuff

restarted everything and now i get server 500 error - We're sorry, but something went wrong.

I don't want to give up, but i checked the logs in appname/shared/logs/production.log but can't see anything there, maybe i'm looking in the wrong place...

Posted in Ruby issue when doing cap deploy production

ok last bit of help needed and i think we're ready to roll!

So i now get this error saying - Incomplete response received from application after restarting passenger and the nginx server, i've googled a couple of things and one link (below) says something to do with the <%= ENV["SECRET_KEY_BASE"] %> in secrets.yml

I'm confused, i thought this was for AWS storage of images etc etc...

How do i rectify this?

http://stackoverflow.com/questions/29241053/incomplete-response-received-from-application-from-nginx-passenger

Posted in Ruby issue when doing cap deploy production

ok i've followed that somewhat haha (i was actually looking at that same link before you sent it through)

so i did the following

template1=# CREATE USER deploy WITH PASSWORD 'somepassword' SUPERUSER;

then made my way over to - /home/deploy/myapp/current
and ran - RAILS_ENV=production bundle exec rake db:create

seems to have worked a treat... i'll finish off the rest of your tutorial, and fingers crossed no more errors! :)

Cheers again for all the help
Gareth

Posted in Ruby issue when doing cap deploy production

Hey Chris,

Yeah i've been googling it and came across a couple of resources, most say i should run the following command -

psql -U your_username postgres

psql postgres
ALTER ROLE that_username CREATEDB

but that didn't seem to work as i still get that error... I'm not entirely sure how to create a db manually as the postgres user.... i'll google it a bit.... so close i can smell the cogs on the server burning! haha

Posted in Ruby issue when doing cap deploy production

So after my wishful thinking of everything running smoothly i've tried the command - RAILS_ENV=production bundle exec rake db:create under the /home/deploy/myapp/current folder (i changed the mayor to my app name ) but i got the error - PG::InsufficientPrivilege: ERROR: permission denied to create database

Any help on this would be great!

Posted in Ruby issue when doing cap deploy production

If ever any one comes up with an issue with activeadmin and it failing with : NameError: uninitialized constant ActiveAdmin
--- I added

require 'activeadmin'

--- to the top of the initializers/active_admin.rb file, not sure if this breaks anything else but that fixed an issue for me see post - https://github.com/activeadmin/activeadmin/issues/1992

I then ran into the javascript problem and installed nodes, as per Anthony's reply above and that worked and it seems to have finished the deployment with out any other issue.... about to restart everything and check it out....

Posted in Simple newsletter sign up?

It's all down to you and James :) so thanks a bunch...

I'm just stuck with two things now, getting it on digital ocean, which I'm trying to figure out through your deploy guide, and why my Nibli logo isn't playing nicely and being responsive... Grrr :)