On windows, make sure you set git to use unix line endings when checking out and committing.
If you've already checked out and have windows line endings, you may encounter
an error stating: env: ruby\r: No such file or directory
. To resolve, run
find ./ -type f -exec dos2unix {} \;
.
After a clean install of this repo, you'll need to run bundle install
inside
the CarriesCloset
root folder. This will install all needed requirements.
Additionally, duplicate the file example.env
in the root level directory.
Once duplicated, rename the duplicate, e.g. example.env (1)
, to just .env
.
This may cause the .env
to disapear from your file brower, but don't worry
if you've named the file correctly.
You'll need to have MySQL installed and running locally.
Depending on whether or not you've run the Rails server recently, or if you're having troubles with your database/server, you'll want to run the following:
bin/rails db:drop
bin/rails db:create db:migrate db:seed
-
You can preview a sample email at http://localhost:3000/rails/mailers/user_mailer/ by clicking on new email.
-
Accessing Environment Variables Containing GMAIL Account info:
- Make a copy of
config\EXAMPLE_local_env.yml
in the config file and rename it justlocal_env.yml
. This way the SMTP settings will have access to the GMAIL login info.
- Make a copy of
-
When you hit the create request button,
- you can see the html and text versions of the confirmation email in your terminal.
- you should also receive the actual email from Carrie's Closet ([email protected]) at the email address you entered on the form, so make sure you enter a valid address.
-
If you want to temporarily disable email deliveries (you'll still be able to see them in you terminal):
- navigate to
config\environments\development.rb
- search for the line
config.action_mailer.perform_deliveries = true
- change it to
config.action_mailer.perform_deliveries = false
- restart server
Note: that same line is also in
config\environments\production.rb
andconfig\environments\test.rb
, so you can also make that change in those files as well depending on
what environment you are working in.Note: When you want to start receiving emails again, just make those lines
config.action_mailer.perform_deliveries = true
again and restart the server. - navigate to
-
If you get an SMTP Authentication Error, it usually means the environment variable with the GMAIL account info is not working, so follow these steps:
- Go to
config\development.rb
and scroll down to the ActionMailer settings where you will seeuser_name: ENV["GMAIL_USERNAME"],
andpassword: ENV["APP_PASSWORD"]
- Go to
config\EXAMPLE_local_env.yml
and copy theGMAIL_USERNAME
value and paste it in place ofENV["GMAIL_USERNAME"]
(leave the comma at the end of the line). - Copy the
APP_PASSWORD
value and paste it in place ofENV["APP_PASSWORD"]
. - Save and restart server.
Note: that these same lines are also in
config\environments\production.rb
andconfig\environments\test.rb
, so you can also make that change in those files as well
depending on what environment you are working in. - Go to
To install all the packaged Javascript libraries locally (suggested for performance improvements), run:
bin/rails webpacker:install
To run the full app stack, run the following commands:
docker-compose build --parallel
docker-compose up -d
docker exec cc_server bin/rails db:create
docker exec cc_server bin/rails db:environment:set RAILS_ENV=development
docker exec cc_server bin/rails db:migrate db:seed
This will create the cc_mysql
MySQL Docker container, the cc_redis
Redis
caching store, and the cc_server
Rails server. Both commands should complete
without error to let you know everything is running properly. The Rails server
will run on http://127.0.0.1:3000 in most environments.
- Always use
bin/rails
when running commands from the terminal (this will point to the proper Carrie's Closet project) bin/rails console --sandbox
will create a sandboxed version of a REPL-style console, loaded with all the classes and data from your running app. Any changes made in the sandbox will be reverted when youexit
.bin/rails generate Tweet user:references body:text likes:integer
will create aTweet
model that belongs to aUser
model. EachTweet
will be stored in the database with abody
text field and alikes
counter.bin/rails destroy Tweet
will revert all generated files for the previousTweet
model.
To run the full app stack, run the following commands:
docker-compose build --parallel && docker-compose up -d
docker exec cc_server sh -c "bin/rails db:create && bin/rails db:migrate && bin/rails db:seed"
docker exec cc_server sh -c "rails webpacker:install"
Note that on Windows, you may need to run these command seprately. Eg.
docker-compose build --parallel
docker-compose up -d
docker exec cc_server sh -c "bin/rails db:create"
docker exec cc_server sh -c "bin/rails db:migrate"
docker exec cc_server sh -c "bin/rails db:seed"
docker exec cc_server sh -c "rails webpacker:install"
This will create the cc_mysql
MySQL Docker container, the cc_redis
Redis
caching store, and the cc_server
Rails server. Both commands should complete
without error to let you know everything is running properly. The Rails server
will run on http://127.0.0.1:3000 in most environments.