1
嗨,我創建了一個控制器的文章,並添加以下代碼在自定義創建的意見沒有輸出
def chid @message='hello world' respond_to do |format| format.html end end
我然後創建
chid.html.erb文件中
app/views/articles/
,並寫了下面的代碼
Hello world
當我給了以下網址
../articles/chid我沒有得到任何輸出..我錯過了什麼?
我的日誌部分
Processing ArticlesController#show (for 127.0.0.1 at 2011-01-12 21:51:01) [GET] Session ID: BAh7BzoMY3NyZl9pZCIlMTA0ZWY2ZTUzYjQxZGJkZmFlMTQwNWRjYjczNTRm%0AODAiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh%0Ac2h7AAY6CkB1c2VkewA%3D--de7737601817f52c1b72daca6061c5126f3a5022 Parameters: {"action"=>"show", "id"=>"chid", "controller"=>"articles"} Rendering template within layouts/articles Rendering articles/show Completed in 0.01000 (100 reqs/sec) | Rendering: 0.00600 (60%) | DB: 0.00000 (0%) | 200 OK [localhost/articles/chid/]
我router.rb文件如下
ActionController::Routing::Routes.draw do |map| map.resources :articles map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' map.match ':controller/:action/' => 'Article#chid' end
您是否設置了路線? – 2011-01-12 17:26:35
@Matheus:不是我應該在那裏做嗎?對不起我正在學習ROR – CHID 2011-01-12 17:35:52