Friday, April 8, 2011

Setup Active Scaffold with rails 3 using jQuery

by Sandip Ransing 0 comments

Create new rails project
rails new demo -d mysql Add active_scaffold gem to bundler
gem "active_scaffold_vho" Run bundle install command
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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-ZMWWFqS0JIx8SO4fMtFcThe0WVs4Kd9pqOmQE9w6CwKU57B0UiWrs0ujwR6bEGKEJrq2wUHVlGIAo0a8_APhd625bYYtgtdfLBPqDvXz1ZEm2v49IG05tC_Bi4sOGt22DvIUn2TarD57/s1600/active_scaffold.png

blog comments powered by Disqus

About The Author

Sandip is a ruby on rails developer based in pune and also a blogger at funonrails. Opensource contributor and working with Josh software Private Limited. for more info read Follow Sandip on Twitter for updates.

Connect With Me...

Github Projects

@sandipransing Twitter