Presentation is loading. Please wait.

Presentation is loading. Please wait.

Creating rails app. p:\InstantRails\rails_apps>rails -d mysql cars create create app/controllers create app/helpers create app/models create app/views/layouts.

Similar presentations


Presentation on theme: "Creating rails app. p:\InstantRails\rails_apps>rails -d mysql cars create create app/controllers create app/helpers create app/models create app/views/layouts."— Presentation transcript:

1 Creating rails app

2 p:\InstantRails\rails_apps>rails -d mysql cars create create app/controllers create app/helpers create app/models create app/views/layouts create config/environments create config/initializers create db create doc create lib create lib/tasks create log

3 Change to cars dir P:\InstantRails\rails_apps>cd cars P:\InstantRails\rails_apps\cars>rake db:create:all (in P:/InstantRails/rails_apps/cars) P:\InstantRails\rails_apps\cars>ruby script/generate scaffold Corvette body_styl e:string miles:float year:integer exists app/models/ exists app/controllers/ exists app/helpers/ create app/views/corvettes exists app/views/layouts/ exists test/functional/ exists test/unit/ create app/views/corvettes/index.html.erb ….(more)

4 Instantrails/railsapps/cars/db/migrate/ 001_create_corvettes.rb class CreateCorvettes < ActiveRecord::Migration def self.up create_table :corvettes do |t| t.string :body_style t.float :miles t.integer :year t.timestamps end def self.down drop_table :corvettes end

5 Create db by running migrate P:\InstantRails\rails_apps\cars>rake db:migrate (in P:/InstantRails/rails_apps/cars) == 1 CreateCorvettes: migrating ========================================== ===== -- create_table(:corvettes) -> 0.0780s == 1 CreateCorvettes: migrated (0.0780s) ======================================

6 Run server… from p drive it is all very slow P:\InstantRails\rails_apps\cars>ruby script/server => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment...

7 Startup screen

8 Form to create new car

9 After creating a car

10 App/models/corvette.rb --- adding validation class Corvette < ActiveRecord::Base validates_presence_of :body_style, :miles, :year validates_numericality_of :year, :greater_than=>1952, :less_than_or_equal_to=>Time.now.year end

11 Entering bad content


Download ppt "Creating rails app. p:\InstantRails\rails_apps>rails -d mysql cars create create app/controllers create app/helpers create app/models create app/views/layouts."

Similar presentations


Ads by Google