Dev box
I'm a 32-year-old Ruby on Rails web developer. With the help of friends and co-workers, I've been teaching myself Rails. I worked as a Rails developer for Crowd911 in Colorado. I live in Berlin.
In my developer blog I publish a stochastic array of thoughts and ideas, lessons, mistakes, questions and attempts as answers about Rails and Ruby. I am also posting Anki cards that I used to help myself study. In my view most knowledge is about practice. If you have thoughts, questions, ideas, corrections, arguments, feel free to email me at henryvw@gmail.com.

Downloading an RDS Database from AWS

1. Create a Snapshot of the database you want to download

2. In the "Snapshots" Section, click "Restore" on the Snapshot. This will create a new database from the snapshot.

3. From your Console, enter a command, pg_dump -h henry-june-12.cmkhjgf43.eu-central-1.rds.amazonaws.com -U root -f dump.sql stock_observer_production

    henry-june-12.cmkhjgf43.eu-central-1.rds.amazonaws.com is the URL for the database

    -h, -U and -f are unknown commands that are apparently umportant

    "root" here is the username on the database

     dump.sql is the name you will give to the data file you will save

     stock_observer_production is the name of the database itself

After that you will be asked for your password to the database.

Finally, you will get a dump of your database saved in a folder, e.g. dump.sql

 

(Now you can do stuff like, change it from an SQL to a CSV file using the steps detailed in the previous blog post)

Read More

Procfiles and Foreman for Rails

A Procfile "Process File" is a way to list multiple processes for an application to start.

You can write processes like this:
web: bundle exec thin start job: bundle exec rake jobs:work

Foreman is a gem to run the contents of a Procfile together.

- foreman run
- foreman start
Read More

How to do PostGres Data to CSV

Create a new empty database

createdb june-12-valendo

Import the data dump.sql into the new database:

psql june-12-valendo < dump.sql

Create the CSV file. It must first exist in order to be able to copy to it.

touch data-june-12.csv

Give PostGres Access to the Folder and Files

chmod a+rw ~/workspace/postgres_data_accessible_to_postgres

Access the database

psql june-12-valendo

List all tables and pick the interesting/important ones

\d

Copy using a SQL command

COPY interesting_field TO '/workspace/postgres_data_accessible_to_postgres/valendo_data-jun-12-2017.csv' DELIMITER ',' CSV HEADER;

Instead of using a SQL command, you can also use a database command. Note that, in that case, the relative value "~" is important for the file:

\copy ar_internal_metadata to '~/workspace/postgres_data_accessible_to_postgres/valendo_data-jun-12-2017.csv' csv header

https://stackoverflow.com/questions/1120109/export-postgres-table-to-csv-file-with-headings

Read More

rspec / rails - "assigns"

The "assigns" method is actually a Rails method that dives into a Controller and grabs an instance variable.

e.g.

Controller

def controller_action

  @rehearsals = Rehearsals.all

end

 

instance_variable_that_I_want_for_example_to_test = assigns(:rehearsals)

Read More

Git & GitHub Branches - Master & Staging

Lesson from CleanAgents Project.

I deployed a branch from Staging. It broke everything.

I was so confused. Wasn't Staging the default branch on GitHub?

Yes. It was. But it WASN'T the branch that was deployed last. (By Capistrano).

Lesson: Always check either the REVISION file on the server (by SSH'ing in) or the Git Log on the server, to see the last commits, and which branch they were from. (AND also ASK which branch is the one being used). Do NOT just assume that because one branch is behind in commits it is the right one.

Read More






Footerfull