我正在尝试学习 Ruby on Rails 并尝试手动编写一些代码,以便了解它是如何工作的。
我做了这个小控制器:
class TestsController < ApplicationController
def test
def show
render :text => "Hi from TestsController!"
end
end
end
这就是我的观点:
<h3> Hello test </h3>
这是我的 routes.rb 片段:
resource :test
但它给出了一个错误:The action 'show' could not be found for TestsController
谢谢!
这是 rake 路由的输出:
home_index GET /home/index(.:format) home#index
root / home#index
test POST /test(.:format) tests#create
new_test GET /test/new(.:format) tests#new
edit_test GET /test/edit(.:format) tests#edit
GET /test(.:format) tests#show
PUT /test(.:format) tests#update
DELETE /test(.:format) tests#destroy