Manual Installation

  1. Create mochi.cr in initalizers and paste this in:

     require "mochi"
  2. Create a migration and paste in:

    Granite:

    ```sql -- +micrate Up CREATE TABLE users ( id INTEGER NOT NULL PRIMARY KEY, email VARCHAR, password_digest VARCHAR, created_at TIMESTAMP, updated_at TIMESTAMP );

  -- +micrate Down
  DROP TABLE IF EXISTS users;
```

or

**Jennifer:**

```crystal
class CreateUser < Jennifer::Migration::Base
  def up
    create_table(:users) do |t|
      t.string :email
      t.string :password_digest
      t.timestamp :created_at
      t.timestamp :updated_at
    end
  end

  def down
    drop_table(:users)
  end
end
```
  1. Migrate:

    Granite:

    or

    Jennifer:

  2. Create a controller titled user_controller.cr and paste in this file:

    user_controller

  3. Create a controller titled session_controller.cr and paste in this file:

    session_controller

  4. Add these to your routes:

    Change pipeline :web to pipeline :web, :auth and add:

    Create an :auth pipeline with:

    Create a new route section just for :auth:

    Add this to your :web routes:

  5. Create a piple titled authenticate.cr and paste in this file:

    authenticate

  6. Copy & Paste all the views found here:

    Views

  7. Add a model:

    Granite:

    user

    or

    Jennifer:

    user{:target="_blank"}

  8. Open config/application.cr and between the # Start Generator & # End Generator add:

  9. Open application_controller.cr and add:

  10. Done! And that's why we have a CLI.

Last updated

Was this helpful?