Skip to content

Create setup script. #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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