Sha256: 51b31a9cf86d903e591f2890c06147808c0f95f60eaa2e30e66a6cbac3dd50ec

Contents?: true

Size: 1.06 KB

Versions: 13

Compression:

Stored size: 1.06 KB

Contents

require 'rubygems'
require 'ramaze'
require 'sequel'
require 'scaffolding_extensions'

# More information on Scaffolding Extensions here: http://scaffolding-ext.rubyforge.org/

DB = Sequel.sqlite

# Sequel::Model doesn't support schema creation by default
# So we have to load it as a plugin
Sequel::Model.plugin :schema

class User < Sequel::Model(:user)
  set_schema do
    primary_key :id
    varchar :name
    text :description
  end

  create_table unless table_exists?
  
  # Add a couple of users to our database
  create(:name => 'manveru', :description => 'The first user!')
  create(:name => 'injekt', :description => 'Just another user')
end

ScaffoldingExtensions.all_models = [User]

class UserController < Ramaze::Controller
  map '/user'
  scaffold_all_models :only => [User]
end

class MainController < Ramaze::Controller
  def index
    %{Scaffolding extension enabled for
      <a href="http://sequel.rubyforge.org/classes/Sequel/Model.html">
      Sequel::Model
      </a> User.
      You can access the scaffolded Model at #{a('/user')}}
  end
end

Ramaze.start

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ramaze-2023.01.06 examples/misc/sequel_scaffolding.rb
ramaze-2012.12.08 examples/misc/sequel_scaffolding.rb
ramaze-2012.12.08b examples/misc/sequel_scaffolding.rb
ramaze-2012.04.14 examples/misc/sequel_scaffolding.rb
ramaze-2012.03.07 examples/misc/sequel_scaffolding.rb
ramaze-2011.12.28 examples/misc/sequel_scaffolding.rb
ramaze-2011.10.23 examples/misc/sequel_scaffolding.rb
ramaze-2011.07.25 examples/misc/sequel_scaffolding.rb
ramaze-2011.01.30 examples/misc/sequel_scaffolding.rb
ramaze-2011.01 examples/misc/sequel_scaffolding.rb
ramaze-2010.06.18 examples/misc/sequel_scaffolding.rb
ramaze-2010.04.04 examples/misc/sequel_scaffolding.rb
ramaze-2010.04 examples/misc/sequel_scaffolding.rb