Rails - Vuejs run with Foreman - ruby-on-rails

I'm try to start my first application with ruby on rails and vuejs.
I use https://mkdev.me/en/posts/rails-5-vue-js-how-to-stop-worrying-and-love-the-frontend to learn and create my application as a tutorial.
Everything is good but when i try to run $ foreman start my cmd throws some error:
21:48:11 frontend.1 | internal/modules/cjs/loader.js:596
21:48:11 frontend.1 | throw err;
21:48:11 frontend.1 | ^
21:48:11 frontend.1 |
21:48:11 frontend.1 | Error: Cannot find module 'ajv'
21:48:11 frontend.1 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
21:48:11 frontend.1 | at Function.Module._load (internal/modules/cjs/loader.js:520:25)
21:48:11 frontend.1 | at Module.require (internal/modules/cjs/loader.js:650:17)
21:48:11 frontend.1 | at require (internal/modules/cjs/helpers.js:20:18)
21:48:11 frontend.1 | at Object.<anonymous> (C:\Users\Hieu Vo\AppData\Roaming\npm\node_modules\webpack\node_modules\schema-utils\src\validateOptions.js:11:13)
21:48:11 frontend.1 | at Module._compile (internal/modules/cjs/loader.js:702:30)
21:48:11 frontend.1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
21:48:11 frontend.1 | at Module.load (internal/modules/cjs/loader.js:612:32)
21:48:11 frontend.1 | at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
21:48:11 frontend.1 | at Function.Module._load (internal/modules/cjs/loader.js:543:3)
Here is my Procfile:
rails: rails s -p 3000
frontend: webpack-dev-server
I hope you can help me resolve this issue. Thank you very much.

Try
npm install ajv
Then run again

Related

When Trying run yarn, throw err; (Ubuntu)

When installing a development environment on my computer with yarn, I get the following error. I have already deleted NVM and YARN and reinstalled them but still, I get the same error:
yarn stg
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module '/mnt/c/Users/David/.yarn/releases/yarn-3.2.0.cjs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Unnecessary files are generated when rails application is launched

ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
This began to occur after tweaking the settings around --binstubs.
The following are generated files.
bin/brakeman
bin/bundle-audit
bin/bundler-audit
bin/byebug
bin/cap
bin/capify
bin/chromedriver-helper
bin/chromedriver-update
bin/coderay
bin/console
bin/dotenv
bin/fission
bin/fog
bin/foreman
bin/generate-api
bin/haml
bin/htmldiff
bin/httpclient
bin/ldiff
bin/listen
bin/maruku
bin/marutex
bin/nokogiri
bin/pry
bin/rackup
bin/rbvmomish
bin/restclient
bin/rspec
bin/rubocop
bin/ruby-parse
bin/ruby-rewrite
bin/sass
bin/sass-convert
bin/scss
bin/sprockets
bin/thor
bin/tilt
bin/unicorn
bin/unicorn_rails
bin/whenever
bin/wheneverize
The following is the message on the terminal.
20:39:07 web.1 | Beginning in Rails 4, Rails ships with a `rails` binstub at ./bin/rails that
20:39:07 web.1 | should be used instead of the Bundler-generated `rails` binstub.
20:39:07 web.1 |
20:39:07 web.1 | If you are seeing this message, your binstub at ./bin/rails was generated by
20:39:07 web.1 | Bundler instead of Rails.
20:39:07 web.1 |
20:39:07 web.1 | You might need to regenerate your `rails` binstub locally and add it to source
20:39:07 web.1 | control:
20:39:07 web.1 |
20:39:07 web.1 | rails app:update:bin # Bear in mind this generates other binstubs
20:39:07 web.1 | # too that you may or may not want (like yarn)
20:39:07 web.1 |
20:39:07 web.1 | If you already have Rails binstubs in source control, you might be
20:39:07 web.1 | inadverently overwriting them during deployment by using bundle install
20:39:07 web.1 | with the --binstubs option.
20:39:07 web.1 |
20:39:07 web.1 | If your application was created prior to Rails 4, here's how to upgrade:
20:39:07 web.1 |
20:39:07 web.1 | bundle config --delete bin # Turn off Bundler's stub generator
20:39:07 web.1 | rails app:update:bin # Use the new Rails executables
20:39:07 web.1 | git add bin # Add bin/ to source control
20:39:07 web.1 |
20:39:07 web.1 | You may need to remove bin/ from your .gitignore as well.
20:39:07 web.1 |
20:39:07 web.1 | When you install a gem whose executable you want to use in your app,
20:39:07 web.1 | generate it and add it to source control:
20:39:07 web.1 |
20:39:07 web.1 | bundle binstubs some-gem-name
20:39:07 web.1 | git add bin/new-executable
20:39:07 web.1 |
Which setting should I change to fix it?

Creating postgres database on Heroku with Rails 4 error

PG::UndefinedTable: ERROR
I am trying to deploy a Rails 4 app on Heroku with a postgres database. I have precompiled assets, but now when I run:
heroku run rake db:migrate
I get this error:
PG::UndefinedTable: ERROR: relation "users" does not exist
: ALTER TABLE "users" ADD COLUMN "invited_by_user_id" integer
rake aborted!
Commonly suggested solutions on Stack Overflow:
I have tried resetting the database with:
heroku pg:reset
The database resets, but I still can't run db:migrate.
I have also tried:
heroku run db:setup
but I get an error that says:
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
I was using Rails 4.1.8, and saw this question which suggested maybe I needed to update to rails 4.1.9 or above, but even now that I'm using Rails 4.2.2, no luck.
Additional possibly relevant info:
Connecting to the postgres database on heroku with
heroku pg:psql
then listing the databases with '\l' gives me a long list of databases with cryptic names:
Name | Owner | Encoding | Collate | Ctype | Access privileges
----------------+----------------+----------+-------------+-------------+-----------------------------------
d100o5a2gii5he | rdxtahlqikernc | UTF8 | en_US.UTF-8 | en_US.UTF-8 | rdxtahlqikernc=CTc/rdxtahlqikernc
d102ehvv3umqam | ibuffadisyolrb | UTF8 | en_US.UTF-8 | en_US.UTF-8 | ibuffadisyolrb=CTc/ibuffadisyolrb
d103n2kea6j5sa | tzzkfcinullytw | UTF8 | en_US.UTF-8 | en_US.UTF-8 | tzzkfcinullytw=CTc/tzzkfcinullytw
d10597iiu347nk | eltovdzaxajtiu | UTF8 | en_US.UTF-8 | en_US.UTF-8 | eltovdzaxajtiu=CTc/eltovdzaxajtiu
d108g0imdgn865 | pvzysfivyhcnaa | UTF8 | en_US.UTF-8 | en_US.UTF-8 | pvzysfivyhcnaa=CTc/pvzysfivyhcnaa
...
dvs2j8tkv153m | zjefhzzizozpwy | UTF8 | en_US.UTF-8 | en_US.UTF-8 | zjefhzzizozpwy=CTc/zjefhzzizozpwy
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | postgres=CTc/postgres
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | postgres=CTc/postgres
(4787 rows)
I'm not sure exactly how to interpret that.
I am relatively new new to Rails, but have successfully setup several databases on Heroku in the past. Following the Heroku documentation hasn't helped, and I'm not sure where to go from here.
How can I get db:migrate to complete without errors?
NOTE: I solved this just after posting. See answer below.
Minutes after posting this question I figured it out, and I'm hoping this might help someone else out.
The solution was to upgrade from Rails 4.1.8 to Rails 4.2.2.
Then run
heroku run rake db:schema:load
before
heroku run rake db:migrate
For some reason that wouldn't run for my project with Rails 4.1.8. So, after upgrading to Rails 4.2.2, I ran the schema load and migrate commands with no errors.

Thin Foreman stopped working

I'm using Thin webserver with RoR on my iMac.
I start it with $ foreman start
It was working fine, but now I'm getting this in the console:
09:27:10 web.1 | => Booting Thin
09:27:10 web.1 | => Rails 3.1.3 application starting in development on http://0.0.0.0:5000
09:27:10 web.1 | => Call with -d to detach
09:27:10 web.1 | => Ctrl-C to shutdown server
09:27:10 web.1 | >> Thin web server (v1.3.1 codename Triple Espresso)
09:27:10 web.1 | >> Maximum connections set to 1024
09:27:10 web.1 | >> Listening on 0.0.0.0:5000, CTRL+C to stop
09:27:10 web.1 | Exiting
09:27:11 web.1 | process terminated
09:27:11 system | sending SIGTERM to all processes
And the $ prompt shows up - so the webserver isn't running.
Any ideas?
I just ran $ thin start
and got:
Using rack adapter
/Users/burtondav/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.22/lib/bundler/runtime.rb:31:in `block in setup': You have already activated rack 1.4.1, but your Gemfile requires rack 1.3.6. Using bundle exec may solve this. (Gem::LoadError)
What bundle exec command should I try?
Add the gem 'thin' in your application Gemfile and execute the bundle exec thin start to resolve the version conflict problem.

Rails 2.3.2.1 error with Litespeed 4.0.5

I just upgraded to Rails 2.3.2.1 running Litespeed web server 4.0.5 and get the below error. I think it has something to do with setting up the Rack preference (server = Rack::Handler::LSWS) but not sure how to do it.
Also, I'm running the lateast ruby-lsapi
[root#idev logs]# gem list ruby-lsapi
ruby-lsapi (3.5, 3.3, 3.2)
2009-07-14 20:31:55.326 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] [STDERR] /home/web/dev/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:22:in `__send__'
2009-07-14 20:31:55.326 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] [STDERR] :
2009-07-14 20:31:55.326 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] [STDERR] undefined method `env_table' for nil:NilClass
2009-07-14 20:31:55.326 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] [STDERR] (
2009-07-14 20:31:55.326 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] [STDERR] NoMethodError
2009-07-14 20:31:55.326 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] [STDERR] )
2009-07-14 20:31:55.326 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] [STDERR] from /home/web/dev/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:22:in `dispatch_cgi'
2009-07-14 20:31:55.326 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] [STDERR] from /home/web/dev/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:102:in `dispatch_cgi'
2009-07-14 20:31:55.326 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] [STDERR] from /home/web/dev/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:28:in `dispatch'
2009-07-14 20:31:55.326 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] [STDERR] from /var/lsws/fcgi-bin/RailsRunner.rb:32
2009-07-14 20:31:56.606 [INFO] [208.68.173.115:57853-0#dev.halomonitor.com] connection to [uds://tmp/lshttpd/dev.halomonitor.com:_.sock] on request #0, confirmed: 1, Connection reset by peer!
2009-07-14 20:31:56.606 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] [uds://tmp/lshttpd/dev.halomonitor.com:_.sock] Request in process stage, fail with 503
2009-07-14 20:31:56.606 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] oops! 503 Service Unavailable
2009-07-14 20:31:56.606 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] Content len: 0, Request line:
GET / HTTP/1.1
2009-07-14 20:31:56.606 [NOTICE] [208.68.173.115:57853-0#dev.halomonitor.com] Redirect: #2, URL: /dispatch.lsapi
$ ruby script/about
About your application's environment
Ruby version 1.8.6 (i386-mswin32)
RubyGems version 1.3.1
Rack version 1.0 bundled
Rails version 2.3.2
Active Record version 2.3.2
Action Pack version 2.3.2
Active Resource version 2.3.2
Action Mailer version 2.3.2
Active Support version 2.3.2
Edge Rails revision e47e2f3c5e23acc07918e3d34546b06c9c0c986c
Application root c:/chirag no backup/rails-2.3.2.1
Environment development
Database adapter postgresql
Database schema version 20090709140613
I thought lightspeed was considered out of the running a while back...
Go for Phusion's Passenger. Way more flexible and easier to setup/configure. Gets rid of dealing with CGI altogether. Check it out, even if you don't go with it.
From the error message undefined method env_table for nil:NilClass, it seem that the code is getting a not initialized value, and it is trying to execute the method env_table on that value.
What is the content of the line 22, in cgi_progress.rb?
I found the answer:
http://www.litespeedtech.com/support/forum/showthread.php?t=3741

Resources