Skip to content

Commit

Permalink
Create setup script.
Browse files Browse the repository at this point in the history
Issues
------
- Closes #42
  • Loading branch information
stevepolitodesign committed Jan 3, 2022
1 parent d4e2638 commit ae7e389
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bin/rails server -p 3000
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

If you're like me then you probably take Devise for granted because you're too intimidated to roll your own authentication system. As powerful as Devise is, it's not perfect. There are plenty of cases where I've reached for it only to end up constrained by its features and design, and wished I could customize it exactly to my liking.

Fortunately, Rails gives you all the tools you need to roll your own authentication system from scratch without needing to depend on a gem. That challenge is just knowing how to account for edge cases while being cognizant of security and best practices.
Fortunately, Rails gives you all the tools you need to roll your own authentication system from scratch without needing to depend on a gem. The challenge is just knowing how to account for edge cases while being cognizant of security and best practices.

## Local Development

Simply run the setup script and follow the prompts to see the final application.

```bash
./bin/setup
```

## Step 1: Build User Model

Expand Down
9 changes: 9 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

if ! command -v foreman &> /dev/null
then
echo "Installing foreman..."
gem install foreman
fi

foreman start -f Procfile.dev
3 changes: 3 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ FileUtils.chdir APP_ROOT do
# end

puts "\n== Preparing database =="
system! 'bin/rails db:reset'
system! 'bin/rails db:prepare'

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system! 'bin/rails restart'

system! 'bin/rails post_setup_instructions:perform'
end
8 changes: 8 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
puts "\n== Creating user =="

User.create!(
email: "confirmed_user@example.com",
password: "password",
password_confirmation: "password",
confirmed_at: Time.current
)
10 changes: 10 additions & 0 deletions lib/tasks/post_setup_instructions.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace :post_setup_instructions do
desc "Prints instructions after running the setup script"
task perform: :environment do
puts "\n== Setup complete 🎉 =="
puts "👉 Run ./bin/dev to start the development server"
puts "\n== You can login with the following account 🔐 =="
puts "Email: confirmed_user@example.com"
puts "Password: password"
end
end

0 comments on commit ae7e389

Please sign in to comment.