LoginSignup
1
2

More than 5 years have passed since last update.

RubyフレームワークのRamazeを使ってみる

Last updated at Posted at 2018-04-20

Ramazeについて

RubyのフレームワークではRoRやSinatraが有名だが今回はRamazeというフレームワークを使ってみました。

http://ramaze.net
https://github.com/Ramaze/ramaze

特徴

Rubyの文法を忠実に使用しているという感じ。

Ramazeのインストール方法

公式にある下記のコマンドでインストール

$ gem install ramaze
$ ramaze create アプリ名

Ramazeの起動

$ cd アプリ名
$ rake ramaze:start

すると localhost:7000 でアクセスできるようになります。

Welcome画面
スクリーンショット 2018-04-20 10.17.41.png

Ramazeのディレクトリ

スクリーンショット 2018-04-20 13.40.39.png

アプリの画面を作る

試しにcontrollerの直下に ramaze.rb というファイルを作成します。

ramaze.rb
require 'ramaze'

class MyController < Ramaze::Controller
  map '/'

  def index
    return "Hello, Ramaze!"
  end
end

Ramaze.start

mapにルーティングを指定します。
今回はルートパスですね。

この状態で ruby ramaze.rb をターミナルから実行します。

localhost:7000 にアクセスすると Hello, Ramaze! が表示されます。

わからないこと

・ページ数を増やしたいときにcontrollerにファイルを増やさないといけないのか。
・各ファイルの記述の意味がわからない。

1
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
1
2