Welcome to our team Github repo! Here you can find all of the resources for our website (folders to be uploaded soon).
- Fork a branch to work on, and merge-push when you're done. Coordinate with team members who are working on similar things through Slack (https://changenuity.slack.com/messages/general/) to avoid clashes.
- Unless you're just updating a small thing, write descriptive commit statements!
- Comment your code to make it understandable by everyone.
- Install Ruby and Rails, maybe use railsinstaller (I think I just manually installed ruby and then rails though)
- Ruby 2.3.~ check with
ruby -v
- Rails 5.0.1~ check with
rails -v
- Bundler is for installing gems easily with the command
bundle install
(just letting you know, don't run it yet) - Sqlite is just for local testing database
- Git is git (version control)
- idk the other stuff in rails installer package, and I'm on Windows so...
- Ruby 2.3.~ check with
- Clone the repo
git clone https://github.com/Changenuity/Changenuity.git
- Go to directory
cd Changenuity
or just open command line in the folder - Run rails server with
rails server
orrails s
- If you get any prompts to install gems, probably run
bundle install --without production
- If a certification error arises, two options:
- Open the gemfile (via windows explorer) and change Source from https://rubygems.org to http://rubygems.org (the difference is the s)
- In CLI
gem sources -r https://rubygems.org
then typegem sources -a http://rubygems.org
To check your sources, typegem sources
- if it says something about data migrations, probably run
rails db:migrate
- If you get any prompts to install gems, probably run
- Navigate to
localhost:3000
in your web browser - TADAA!!! Oh yeah
ctrl-C
theny
to stop the server
Rails generates a bunch of files and configs you mostly don't need to concern yourself with. If you want to check out what everything is for, go here.
app/assets
is where CSS, JS, and other assets like images should beapp/views
is where HTML is stored, the .erb extension indicates embedded ruby which is used for dynamic features and database storage!
Of course there are more things, but for now front-end is just this.
To add the Heroku staging and production remote servers, run git remote add staging https://git.heroku.com/changenuity-staging.git
and git remote add heroku https://git.heroku.com/changenuity.git
.
To push the latest commit from cool-branch into the staging server, run git push staging cool-branch:develop
. To push the latest commit from develop into production, run git push heroku develop
but remember, your changes will be visible on changenuity.com directly! Make sure everybody approves before you push!!
Whenever pushing anything to Heroku that requires migrations, remember to run heroku rake db:migrate
To browse the current state of the database, first download PostgreSQL
- run
heroku pg:backups:capture
to create a backup - run
heroku pg:backups:download
to download it - open the newly saved
latest.dump
from your current folder using PostgreSQL
To edit database entries directly, run heroku run rails console
- run
Model.all
to get a list of all entries of a certain model, e.g.Project.all
orUser.all
- run
Model.where(key1: "value1", key2: "value2")
to get a list of all entries that match a certain query, e.g.Project.where(name: "UBC Orbit")
- run
Model.find(id)
to get the entry with the given id, taken from the URL, e.g.Project.find(7)
orUser.find(1)
- run
first
orlast
to get the first or last entry in a list, e.g.Project.where(location: "Vancouver").last
- assign an entry to a variable to modify it, e.g.
p = Project.find(3)
orp = User.where(email: "eugene@changenuity.com").first
- then modify its attributes directly, e.g.
p.email = awesome@changenuity.com
- run
save
to permanently save your update to the Heroku database
Rails console commands:
ActiveRecord::Base.connection.data_sources