Betatrek web app
This is the source code for betatrek.com
Development environment setup
-
execute
bundle install; bundle --binstubs=./bundler_stubs
to install the gems and set up the bin stubs to omitbundle exec
from the beginning of commands. See. -
install PostgreSQL.
-
To setup PostreSQL databases for development
- execute
createuser betatrek
Superuser? no, Create database? yes, Create new roles? no - execute
psql postgres
to enter the PostgreSQL terminal - enter
ALTER USER betatrek WITH ENCRYPTED PASSWORD 'bettafishswimminginapool';
to add a password. - confirm with
SELECT * FROM pg_user
- execute
createdb -O betatrek betatrek_test
- execute
createdb -O betatrek betatrek_development
- execute
createdb -O betatrek betatrek_production
- Notes:
- confirm their existence with
psql betatrek_<environment>
(i.e.psql betatrek_test
) - in psql terminal tab for SQL autocompletes. "\q" to quit
- confirm their existence with
- Notes:
- in the BetatrekOnRails directory execute
rake db:migrate
(set up schemas),rake db:populate
(fill the databases with sample data) andrake db:test:prepare
(to prepare the test database for the test environment)
- execute
-
open a new terminal to start the guard process. Execute
guard
-
open another terminal to start the server process. Execute
rails server
Development notes
- Can use
rails g
instead ofrails generate
- Can user
rails s
instead ofrails s
- Sometimes it is required to restart the server or guard processes when modifying certain files
- Generate new controllers with
rails g controller **Name** optional list of actions --no-test-framework
(i.e. rails g controller StaticPages home --no-test-framework)- Convention is to use plural nouns for controllers
- Generate new models with
rails g model **Name** optional list of attributes
(i.e. rails g model Rsvp email:string)- Convention is to use singular nouns for models
- Don't forget to set attr_accessible to limit mass assignments
- Generate new test specifications with
rails g integration_test **name**
- List currently defined routes with
rake routes
- When you migrate a database, use
annotate --position before
to add/update annotations in the corresponding model files - Generate new mailers with
rails g mailer **name**
- Generate a new migration with
rails g migration **name**
Deployment
- Commit your changes to your local repository
- Stage untracked files:
git add .
in base directory and confirm withgit status
- Commit all tracked (staged) files:
git commit -am "**Commit note**" (avoid exclamations, or remove the m to enter the message with the default text editor) again, check with
git status`
- Stage untracked files:
- Push your local changes to the remote repository
git push
- Deploy to the server (with Capistrano)
- First time (new app on the server):
cap deploy:setup
to set up the directories on the server. Thencap deploy:cold
to deploy the app on the server - If you're just changing code or configuration:
cap deploy
- If you're just migrating a database:
cap deploy:migrate
- If you're changing code and migrating:
cap deploy:migrations
- You can run commands on the server with `cap invoke COMMAND="Command"
- http://capitate.rubyforge.org/recipes/deploy.html for general deployment recipe documentation
-
ssh-agent forwarding
** To start you're ssh-agent you can use: "exec
ssh-agent
" ** Then to add you're default id_rsa.pub key: "ssh-add" ** Nowssh-add -l
should list your key's fingerprint ** If you want to ssh with the agent:ssh -A -i betatrek.pem …
** Capistrano should be configured to automatically forward your ssh-agent ** Also note that the ssh-agent should expire eventually and would need to be refreshed (ssh-add -l
returns no identities, runssh-add
again).
- First time (new app on the server):
- Success!