Rails 3 migrations: Adding reference column?
If you are using the Rails 4.x you can now generate migrations with references, like this: rails generate migration AddUserRefToProducts user:references like you can see on rails guides
If you are using the Rails 4.x you can now generate migrations with references, like this: rails generate migration AddUserRefToProducts user:references like you can see on rails guides
You need to use kill -9 59780 with 59780 replaced with found PID number (use lsof -wni tcp:3000 to see which process used 3000 port and get the process PID). Or you can just modify your puma config change the tcp port tcp://127.0.0.1:3000 from 3000 to 9292 or other port that not been used. Or … Read more
Pass an argument to round containing the number of decimal places to round to >> 2.3465.round => 2 >> 2.3465.round(2) => 2.35 >> 2.3465.round(3) => 2.347
str = “\x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a”.force_encoding(‘ASCII-8BIT’) puts CGI.escape str => “%124Vx%9A%BC%DE%F1%23Eg%89%AB%CD%EF%124Vx%9A”
You would do Person.where(‘name=? OR lastname=?’, ‘John’, ‘Smith’) Right now, there isn’t any other OR support by the new AR3 syntax (that is without using some 3rd party gem).
add_index :people, [:firstname, :lastname, :dob], unique: true
What you posted should work perfectly: class Foo CONSTANT_NAME = [“a”, “b”, “c”] end Foo::CONSTANT_NAME # => [“a”, “b”, “c”]
You can also install gems in your local environment (without sudo) with gem install –user-install <gemname> I recommend that so you don’t mess with your system-level configuration even if it’s a single-user computer. You can check where the gems go by looking at gempaths with gem environment. In my case it’s “~/.gem/ruby/1.8”. If you need … Read more
I ran into the same error above, app was crashing on heroku (running fine in dev) but error logs on heroku were not revealing any clues. I read other answers on this page and broke out in a sweat after seeing “rebuilding the app.” I figured maybe I could get in the heroku console and … Read more
TL;DR Just Run this command to Kill it sudo kill -9 $(lsof -i :3000 -t) Root Cause: Because PID is locked in a file and web server thinks that if that file exists then it means it is already running. Normally when a web server is closed that file is deleted, but in some cases, … Read more