sixarm_rails_demo_devise
SixArm.com » Rails » Demo Devise
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.0%) to scientific vocabulary
Keywords
Repository
SixArm.com » Rails » Demo Devise
Basic Info
- Host: GitHub
- Owner: SixArm
- Language: Ruby
- Default Branch: master
- Size: 33.2 KB
Statistics
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
SixArm » Rails »
Demo Devise authentication
Rails demonstration application that shows how to set up the Devise gem for user authentication.
Start
Create a new Rails application:
sh
rails new demo_devise --database=postgresql --skip-bundle
cd demo_devise
Bundle:
sh
bundle install --path vendor/bundle --binstubs vendor/bundle/binstubs
echo /vendor >> .gitignore
Initialize the database:
sh
bin/rake db:create db:migrate
Test:
sh
bin/rake test
Launch
Start the Rails server:
sh
bin/rails server
Browse http://localhost:3000 and you see the application running.
Home Page
Edit config/routes.rb and change the root path to this:
ruby
root 'home#index'
Generate:
sh
bin/rails generate controller home index
Browse http://localhost:3000 to see the new home page.
Messages
Edit app/views/layouts/application.html.erb and insert these lines after the body tag:
erb
<body>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
Mailers
Edit config/environments/development.rb and add this:
```ruby
Set a default host that will be used in all mailers.
config.actionmailer.defaulturl_options = { host: 'localhost', port: 3000 } ```
Do the same for test.rb and production.rb for now; you will need to change these later.
Generate User
Generate a user:
sh
rails generate resource user name:string
bin/rake db:migrate
Devise
Edit Gemfile:
```ruby
Use Devise for user authentication
gem 'devise' ```
Bundle:
sh
bundle
Verify config/environments/development.rb sets the mailer default, such as:
ruby
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
Verify app/views/layouts/application.html.erb shows messges, such as:
erb
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
Verify config/routes.rb has a root line, such as:
ruby
root 'home#index'
Generate:
sh
rails generate devise:install
rails generate devise user
bin/rake db:migrate
Edit test/fixtures/users.yml and add a unique email address to each user:
yaml
one:
name: MyString
email: user1@example.com
two:
name: MyString
email: user2@example.com
Devise upgrades
Devise upgrades the application and user model with these capabilities:
- encrypted password
- sign in tracking
- confirmable accounts
- lockable accounts
The db/schema.rb users section looks like this:
```ruby createtable "users", force: :cascade do |t| t.string "name" t.datetime "createdat", null: false t.datetime "updatedat", null: false t.string "email", default: "", null: false t.string "encryptedpassword", default: "", null: false t.string "resetpasswordtoken" t.datetime "resetpasswordsentat" t.datetime "remembercreatedat" t.integer "signincount", default: 0, null: false t.datetime "currentsigninat" t.datetime "lastsigninat" t.inet "currentsigninip" t.inet "lastsignin_ip" end
addindex "users", ["email"], name: "indexusersonemail", unique: true, using: :btree addindex "users", ["resetpasswordtoken"], name: "indexusersonresetpasswordtoken", unique: true, using: :btree ```
Devise authentication
Edit app/controllers/home_controller.rb and add authentication:
ruby
class HomeController < ApplicationController
before_action :authenticate_user!
Browse http://localhost:3000/ and you now see the Devise sign in page.
The page says "You need to sign in or sign up before continuing."
Devise sign up
Sign up:
- Email:
alice@example.com - Password:
secretive
You should see: "Welcome! You have signed up successfully."
To see the new user record in Rails:
sh
bin/rails console
```irb
User.first.email User Load (0.7ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 => "alice@example.com" ```
Owner
- Name: SixArm
- Login: SixArm
- Kind: organization
- Email: sixarm@sixarm.com
- Location: San Francisco
- Website: http://sixarm.com
- Twitter: sixarm
- Repositories: 580
- Profile: https://github.com/SixArm
SixArm Software
Citation (CITATION.cff)
cff-version: 1.2.0
title: SixArm » Rails » <br> Demo Devise authentication
message: >-
If you use this work and you want to cite it,
then you can use the metadata from this file.
type: software
authors:
- given-names: Joel Parker
family-names: Henderson
email: joel@joelparkerhenderson.com
affiliation: joelparkerhenderson.com
orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
- type: url
value: 'https://github.com/SixArm/sixarm_rails_demo_devise/'
description: SixArm » Rails » <br> Demo Devise authentication
repository-code: 'https://github.com/SixArm/sixarm_rails_demo_devise/'
abstract: >-
SixArm » Rails » <br> Demo Devise authentication
license: See license file
GitHub Events
Total
- Push event: 1
Last Year
- Push event: 1
Committers
Last synced: 11 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Joel Parker Henderson | j****l@j****m | 11 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- byebug >= 0 development
- sdoc ~> 0.4.0 development
- spring >= 0 development
- web-console ~> 2.0 development
- coffee-rails ~> 4.1.0
- devise >= 0
- jbuilder ~> 2.0
- jquery-rails >= 0
- pg >= 0
- rails = 4.2.0
- sass-rails ~> 5.0
- turbolinks >= 0
- uglifier >= 1.3.0
- actionmailer 4.2.0
- actionpack 4.2.0
- actionview 4.2.0
- activejob 4.2.0
- activemodel 4.2.0
- activerecord 4.2.0
- activesupport 4.2.0
- arel 6.0.0
- bcrypt 3.1.9
- binding_of_caller 0.7.2
- builder 3.2.2
- byebug 3.5.1
- coffee-rails 4.1.0
- coffee-script 2.3.0
- coffee-script-source 1.8.0
- columnize 0.9.0
- debug_inspector 0.0.2
- debugger-linecache 1.2.0
- devise 3.4.1
- erubis 2.7.0
- execjs 2.2.2
- globalid 0.3.0
- hike 1.2.3
- i18n 0.7.0
- jbuilder 2.2.6
- jquery-rails 4.0.3
- json 1.8.2
- loofah 2.0.1
- mail 2.6.3
- mime-types 2.4.3
- mini_portile 0.6.2
- minitest 5.5.1
- multi_json 1.10.1
- nokogiri 1.6.5
- orm_adapter 0.5.0
- pg 0.18.1
- rack 1.6.0
- rack-test 0.6.3
- rails 4.2.0
- rails-deprecated_sanitizer 1.0.3
- rails-dom-testing 1.0.5
- rails-html-sanitizer 1.0.1
- railties 4.2.0
- rake 10.4.2
- rdoc 4.2.0
- responders 2.0.2
- sass 3.4.9
- sass-rails 5.0.1
- sdoc 0.4.1
- slop 3.6.0
- spring 1.2.0
- sprockets 2.12.3
- sprockets-rails 2.2.2
- thor 0.19.1
- thread_safe 0.3.4
- tilt 1.4.1
- turbolinks 2.5.3
- tzinfo 1.2.2
- uglifier 2.7.0
- warden 1.2.3
- web-console 2.0.0