I am trying to learn Ruby on Rails and trying to write some of the code by hand so that I learn how it works.
I made this tiny controller:
class TestsController < ApplicationController
def test
def show
render :text => "Hi from TestsController!"
end
end
end
and this is what is left of my view:
<h3> Hello test </h3>
and this is my routes.rb snippet:
resource :test
but it gives an error that: The action 'show' could not be found for TestsController
Thanks!
This is the output of rake routes:
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
A basic controller looks like this:
You do not need the
respond_toblock if you only want to render the default view (in this case:app/views/tests/show.html.erb). Therespond_toblock is when you have some more advanced needs.