私はコントローラーstreams_controller
とモデルを持っていstreams
ます。
class StreamsController < ApplicationController
def new
@stream = Stream.new
end
def create
@stream = Stream.new(params[:stream])
if @stream.save
flash[:success] = "Welcome!"
redirect_to @stream
else
render 'new'
end
end
def show
@stream = Stream.find(params[:id])
end
end
と
class Stream < ActiveRecord::Base
attr_accessible :name, :email, :password, :password_confirmation
before_save { |stream| stream.name = name.downcase }
has_secure_password
.
.
.
基本的に show メソッドを動作させるにはlocalhost/streams/[id]
、[id] が特定のストリームの ID である場所に移動する必要があります。URL を次のように再ルーティングすることは可能でしょうか: localhost/[name]
[name] は Stream モデルの :name 属性ですか?
したがって、基本的に、新しいストリームが作成されるたびに新しい URL が作成され、データベース内のストリームの名前に対応します。
これを実装するにはどうすればよいですか?
とにかく、助けや考えは大歓迎です!