LoginSignup
3
2

More than 5 years have passed since last update.

Exodusの使い方

Posted at

Exodusとは?

簡単にNimのSinatraライクなWebフレームワークjesterでRailsにちょっとインスパイアされたCRUDなテンプレを作れるコマンドです。

インストール

  1. nimbleでインストールします。
nimble install nim_exodus
  1. nimbleのPATH通してない人はこれ忘れず

fishシェルの方は.config/fish/config.fishに以下を記述します。

set -x PATH ~/.nimble/bin $PATH

もし、bashやzshなどの古い昭和時代のシェルの方は

.bashrc.bash_profile で以下を記述します。

export PATH=$PATH:~/.nimble/bin

作成

userという名前のテーブルで、nameフィールドがあるのを作成します。
※実はまだフィールドが1つしか対応してないので複数のフィールドが欲しい時はアップデートを待ちましょう。
 または自力で追加。

  1. 中身が作れられてしますので、まず、空のディレクトリを作っておきます。
mkdir users_app
cd users_app
  1. 生成
exodus g scaffold user name:string
  1. 以下の分かりやすいコマンドが表示されます。
Yay! Run server command below.
> nim c -r app.nim

If you create db,
> nim c -r app.nim init
  1. dbだけ作っておきたいので、SQLiteのファイルを作っておきます。

※まだ、SQLiteしか非対応ですが、今後MySQLやPostgreSQLもサポートすると思われます。

nim c -r app.nim init

以下が表示されますね。

db was created.

アクセス

  1. 先ほどの分かりやすいコマンドの通り、起動しましょう。
nim c -r app.nim
  1. アクセスします。

  1. 分かりやすい表示が出ます。
GET /users  users#index Show all users
GET /users/new  users#new   show HTML for create a user
POST    /users  users#create create a user
GET /users/:id  users#show show a user
GET /users/:id/edit users#edit show HTML for edit user form
PATCH/PUT   /users/:id  users#update update a user
DELETE  /users/:id  users#destroy delete a user
  1. 一覧をまず観てみましょう。

usersを付与したのでここ。

表示、追加、削除、編集、削除のページが出来ます。

今後

React、Cycle.jsとかのオプション選択などが追加されると思います。

プルリク

  • こちらにできます

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2