I've used ROR in the past,
but recently started working with version 2.2.
I don't seem to be able to get started:
# I create a rails app: @rails music_library@
# I create a db using an SQlite gui: @music_library_DB.rsd@
# I edit the config/database.yml file:
@development:
adapter: sqlite3
database: db/music_library_DB.rsd
pool: 5
timeout: 5000@
#I run @script/generate scaffold Album@
#I run @rake db:migrate@
Afterwards, I run @script/generate migration columns@, so I can add
columns to the @albums@ DB table:
# @class Columns < ActiveRecord::Migration
def self.up
drop_table :albums
create_table :albums do |t|
t.string :title, :artist, :genre
t.datetime :releasedate
t.timestamps
end
end
def self.down
drop_table :albums
end
end@
# I run @rake db:migrate@ again, to execute the migration
And here's my question:
How do I update the scaffolding, so I can use CRUD to add albums, ...
You don’t. Dynamic scaffolding was deprecated after Rails 1.2.x, I believe. Rails 2.0 and beyond actually generate the view files as ERB depending on the model attributes you provide on the command line to create the scaffold.
The preferred way to create a new scaffold now will look something like this:
ruby script/generate scaffold Album title:string artist_name:string release_year:integer ...
This creates a new resource with all the extra REST-ful stuff that comes along with it.
If you want to try installing the old dynamic scaffolding as a plugin, it’s still available (ruby script/plugin install scaffolding should do it), but it’s questionable whether or not it will work with any newer version of the framework.