|
|
Rails
2.0 changes the way Scaffold
works. This blog walks you through the steps to create a simple CRUD
application using Scaffold in Rails 2.0.
jruby -S gem install railscd samples; mkdir rails; cd rails<br>
jruby -S rails books -d mysqlsudo /usr/local/mysql/bin/mysqld_safe --consolecd books<br>
jruby -S rake db:create<br>
db:create:all
Create all the databases (_Development, _Test,
_Production)
db:drop
Drops your database
db:reset
Drop and Re-create your database, including
migrations
<br>
jruby script/generate scaffold book title:string author:string
isbn:string description:text<br>
exists
app/models/<br>
exists
app/controllers/<br>
exists
app/helpers/<br>
create
app/views/books<br>
exists
app/views/layouts/<br>
exists
test/functional/<br>
exists
test/unit/<br>
create
app/views/books/index.html.erb<br>
create
app/views/books/show.html.erb<br>
create
app/views/books/new.html.erb<br>
create
app/views/books/edit.html.erb<br>
create
app/views/layouts/books.html.erb<br>
create
public/stylesheets/scaffold.css<br>
dependency model<br>
exists app/models/<br>
exists test/unit/<br>
exists test/fixtures/<br>
create app/models/book.rb<br>
create test/unit/book_test.rb<br>
create test/fixtures/books.yml<br>
create db/migrate<br>
create db/migrate/001_create_books.rb<br>
create
app/controllers/books_controller.rb<br>
create
test/functional/books_controller_test.rb<br>
create
app/helpers/books_helper.rb<br>
route
map.resources :booksdb/migrate/001_create_books.rb"class CreateBooks < ActiveRecord::Migration<br>
def self.up<br>
create_table :books do |t|<br>
t.string :title<br>
t.string :author<br>
t.string :isbn<br>
t.text :description<br>
<br>
t.timestamps<br>
end<br>
end<br>
<br>
def self.down<br>
drop_table :books<br>
end<br>
endjruby -S rake db:migrate<br>
jruby script/serverhttp://localhost:3000/books"That's it, you've created a simple Rails 2.0 CRUD application.
You can also deploy this application easily on GlassFish
v3 gem. Just follow the instructions here
and enjoy!
I'll post a follow up blog where this is much more simplifed using NetBeans
6.1 builds where JRuby 1.1 and Rails 2.0.2 are already
integrated.
Technorati: totd
ruby
jruby rubyonrails
rails2
scaffold
crud netbeans
glassfish
v3 gem