Wednesday, January 20, 2016
Tuesday, January 19, 2016
Rails 4 Migrations
http://stackoverflow.com/questions/22815009/add-a-reference-column-migration-in-rails-4
When you already have a users and uploads table and wish to add new relationship between them.
All you need to do is, just generate a migration using following command:rails g migration AddUserToUploads user:references
which will create a migration file as:
class AddUserToUploads < ActiveRecord::Migration
def change
add_reference :uploads, :user, index: true
end
end
Then run the migration using rake db:migrate. This migration will take care of adding a new column named user_id to uploads table (referencing id column in users table) PLUS it will also add an index on the new column.
Then run the migration using rake db:migrate. This migration will take care of adding a new column named user_id to uploads table (referencing id column in users table) PLUS it will also add an index on the new column.
Sunday, January 17, 2016
CSS was not working on Heroku
Add CSS to Heroku
To load the css and assets I ran:
$ bundle exec rake assets:precompile
That still didn't work so I ran:
$ RAILS_ENV=production bundle exec rake assets:precompile
The response:
rake aborted!
Devise.secret_key was not set. Please add the following to your Devise initializer:
config.secret_key = (gave me a long number)
It is still not working 12-19-2015 on Linux but it works on Mac
(skeleton works on both)
Tuesday, January 5, 2016
Installing Postgres on Ubuntu
Heroku uses Postgres for their database so it is quite nice to use it as the database for your Rails app. That way there is a seamless transition.
Postgres Command Cheat sheet
This site is helpful if you are a Mac user and can $ `brew install`:
http://www.jackiejohnston.us/blog/setting-up-user-authentication-with-devise/
https://www.codefellows.org/blog/three-battle-tested-ways-to-install-postgresql
http://postgresapp.com/documentation/configuration-ruby.html
I decided to install Postgres it my Ubuntu ThinkPad.
How To Install and Use PostgreSQL on Ubuntu 14.04 https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04
Digital Ocean has great documentation.
How To Setup Ruby on Rails with Postgres https://www.digitalocean.com/community/tutorials/how-to-setup-ruby-on-rails-with-postgres
Postgres Command Cheat sheet
This site is helpful if you are a Mac user and can $ `brew install`:
http://www.jackiejohnston.us/blog/setting-up-user-authentication-with-devise/
https://www.codefellows.org/blog/three-battle-tested-ways-to-install-postgresql
http://postgresapp.com/documentation/configuration-ruby.html
I decided to install Postgres it my Ubuntu ThinkPad.
How To Install and Use PostgreSQL on Ubuntu 14.04 https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04
Digital Ocean has great documentation.
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
How To Setup Ruby on Rails with Postgres https://www.digitalocean.com/community/tutorials/how-to-setup-ruby-on-rails-with-postgres
Subscribe to:
Posts (Atom)