Skip to content

Commit 49727fb

Browse files
committedJan 3, 2022
Create setup script.
Issues ------ - Closes #42
1 parent d4e2638 commit 49727fb

File tree

6 files changed

+40
-1
lines changed

6 files changed

+40
-1
lines changed
 

‎Procfile.dev

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: bin/rails server -p 3000

‎README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
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.
44

5-
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.
5+
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.
6+
7+
## Local Development
8+
9+
Simply run the setup script and follow the prompts to see the final application.
10+
11+
```bash
12+
./bin/setup
13+
```
614

715
## Step 1: Build User Model
816

‎bin/dev

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
if ! command -v foreman &> /dev/null
4+
then
5+
echo "Installing foreman..."
6+
gem install foreman
7+
fi
8+
9+
foreman start -f Procfile.dev

‎bin/setup

+3
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ FileUtils.chdir APP_ROOT do
2626
# end
2727

2828
puts "\n== Preparing database =="
29+
system! 'bin/rails db:reset'
2930
system! 'bin/rails db:prepare'
3031

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

3435
puts "\n== Restarting application server =="
3536
system! 'bin/rails restart'
37+
38+
system! 'bin/rails post_setup_instructions:perform'
3639
end

‎db/seeds.rb

+8
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@
55
#
66
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
77
# Character.create(name: 'Luke', movie: movies.first)
8+
puts "\n== Creating user =="
9+
10+
User.create!(
11+
email: "confirmed_user@example.com",
12+
password: "password",
13+
password_confirmation: "password",
14+
confirmed_at: Time.current
15+
)
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace :post_setup_instructions do
2+
desc "Prints instructions after running the setup script"
3+
task perform: :environment do
4+
puts "\n== Setup complete 🎉 =="
5+
puts "👉 Run ./bin/dev to start the development server"
6+
puts "\n== You can login with the following account 🔐 =="
7+
puts "Email: confirmed_user@example.com"
8+
puts "Password: password"
9+
end
10+
end

0 commit comments

Comments
 (0)