如何处理从原始 HTML 表单传入的参数?
在 /views/feeders/index.html.erb 中:
<form action="/feeders/extract/" method="post" accept-charset="utf-8">
<input type="text" name="url" value="" id="url">
<p><input type="submit" value="submit"></p>
</form>
在 /controllers/feeders_controller.rb
class FeedersController < ApplicationController
def index
@url=params[:url]
end
def show
end
def extract
@url=params[:url]
redirect_to :controller => 'feeders', :action => 'show'
end
end
在 routes.rb 中:
root :to => 'feeders#index'
match '/feeders/extract/:url' => 'feeders#extract', :via => :post
match '/feeders/show/' => 'feeders#show'
我不断得到
Routing Error
No route matches [POST] "/feeders/extract"