File: app\models\cruncher.rb
class Cruncher
def crunch
return 5
end
end
File: app\controllers\hello_controller.rb
class HelloController < ApplicationController
def there
@cruncher = Cruncher.new
@data = @cruncher.crunch
end
end
File: app\views\hello\there.rhtml:
Using Models
Working With Models
This application fetches data from a model.
The fetched data is: <%= @data %>.
Start the WEBrick server: ruby script/server
Navigate to http://localhost:3000/hello/there
workWithModel.zip( 90 k)