I am reading “Pragmatic Agile Web Development with Rails (2th ed)” and trying examples from this book. But when I am trying one of examples I have got error.
So:
-
I have created a model for a product
ruby script/generate model productFilled the fields:
class CreateProducts < ActiveRecord::Migration def self.up create_table :products do |t| t.column :title, :string t.column :description, :text t.column :image_url, :string end end def self.down drop_table :products end endGenerated the DB:
rake db:migrate -
Next I have creaded the view:
ruby script/generate controller adminAdded line to the view:
class AdminController < ApplicationController scaffold :product end-
Have runned the server and have got error:
undefined method `scaffold' for AdminController:Class
-
I have googled and found this solution:
ruby script/generate scaffold product title:string description:text image_url:string
But I am not sure that it is a right way. What is the ‘true way’ to create a view for the product table ?
scaffoldmethod has been removed from Rails since about 2.0 version. Since that time, one should use the generator for scaffolding.