How To Set Up Active Scaffold With Rails 3 Using jQuery

Create new rails project

rails new demo -d mysql

Add active_scaffold gem to bundler

gem "active_scaffold_vho"
bundle install

Setup active scaffold to use jQuery

rails g active_scaffold_setup jquery

create public/javascripts/rails_jquery.js
create public/javascripts/jquery-ui-timepicker-addon.js
create config/initializers/active_scaffold.rb
insert app/views/layouts/application.html.erb
insert config/locales/en.yml
gsub app/views/layouts/application.html.erb

Generate active scaffold for resource city & zone

rails g active_scaffold City name:string

invoke active_record create db/migrate/20110408123206_create_cities.rb
create app/models/city.rb invoke test_unit
create test/unit/city_test.rb
create test/fixtures/cities.yml
route resources :cities do as_routes end
invoke active_scaffold_controller
create app/controllers/cities_controller.rb
create app/helpers/cities_helper.rb invoke test_unit
create test/functional/cities_controller_test.rb
create app/views/cities
rails g active_scaffold Zone name:string city:references

invoke active_record create db/migrate/20110408123531_create_zones.rb
create app/models/zone.rb invoke test_unit
create test/unit/zone_test.rb
create test/fixtures/zones.yml
route resources :zones do as_routes end
invoke active_scaffold_controller create app/controllers/zones_controller.rb
create app/helpers/zones_helper.rb
invoke test_unit create test/functional/zones_controller_test.rb
create app/views/zones

Add Associations

class City < ActiveRecord::Base
end

class Zone < ActiveRecord::Base
belongs_to :city
end

class City < ActiveRecord::Base
has_many :zones
end

Migrate database

rake db:create

rake db:migrate
== CreateCities: migrating ===================================
-- create_table(:cities) -> 0.1411s
== CreateCities: migrated (0.1413s) ==========================
== CreateZones: migrating ====================================
-- create_table(:zones) -> 0.1507s
== CreateZones: migrated (0.1510s) ===========================

Start Server

rails s

Visit Browser URL: http://localhost:3000/cities

Snap
https://joshsoftware.files.wordpress.com/2011/04/active_scaffold.png?w=300

3 thoughts on “How To Set Up Active Scaffold With Rails 3 Using jQuery

  1. When I ran setup I got:

    C:\proj\keyman>rails g active_scaffold_setup jquery
    c:/Ruby192/lib/ruby/1.9.1/net/http.rb:678:in `connect’: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify faile
    d (OpenSSL::SSL::SSLError)
    from c:/Ruby192/lib/ruby/1.9.1/net/http.rb:678:in `block in connect’
    from c:/Ruby192/lib/ruby/1.9.1/timeout.rb:44:in `timeout’
    from c:/Ruby192/lib/ruby/1.9.1/timeout.rb:87:in `timeout’
    from c:/Ruby192/lib/ruby/1.9.1/net/http.rb:678:in `connect’
    from c:/Ruby192/lib/ruby/1.9.1/net/http.rb:637:in `do_start’
    from c:/Ruby192/lib/ruby/1.9.1/net/http.rb:626:in `start’
    from c:/Ruby192/lib/ruby/1.9.1/open-uri.rb:306:in `open_http’
    from c:/Ruby192/lib/ruby/1.9.1/open-uri.rb:769:in `buffer_open’
    from c:/Ruby192/lib/ruby/1.9.1/open-uri.rb:203:in `block in open_loop’
    from c:/Ruby192/lib/ruby/1.9.1/open-uri.rb:201:in `catch’
    from c:/Ruby192/lib/ruby/1.9.1/open-uri.rb:201:in `open_loop’
    from c:/Ruby192/lib/ruby/1.9.1/open-uri.rb:146:in `open_uri’
    from c:/Ruby192/lib/ruby/1.9.1/open-uri.rb:671:in `open’
    from c:/Ruby192/lib/ruby/1.9.1/open-uri.rb:33:in `open’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:77:in `get’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/active_scaffold-3.0.12/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb:18:in
    `install_plugins’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:389:in `start’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/generators.rb:163:in `invoke’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands/generate.rb:10:in `’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `block in require’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `block in load_dependency’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require’
    from c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands.rb:17:in `’
    from script/rails:6:in `require’
    from script/rails:6:in `’

    C:\proj\keyman>

    1. Above command actually goes to jQuery site to download dependency files. It might be the case that you don’t have Internet connection or slow connection problems.

      If problem persists try to manually copy required files.

      1. Thanks for the quick reply Sandip!

        I think that this is maybe something else, even though it is in the timeout method. Note the error message:

        certificate verify failed (OpenSSL::SSL::SSLError)

        Also, my internet connection is great. Also, I could download the files – which ones? Where do I find them, and do they all go into public/javascripts?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.