1 / 11

Creating rails app

Creating rails app. p :InstantRailsails_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

sidone
Download Presentation

Creating rails app

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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:floatyear: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.rbInstantrails/railsapps/cars/db/migrate/001_create_corvettes.rb class CreateCorvettes < ActiveRecord::Migration defself.up create_table :corvettes do |t| t.string :body_style t.float :miles t.integer :year t.timestamps end end defself.down drop_table :corvettes end 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

More Related