Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

深入淺出RoR

748 views

Published on

Reference: RoR Tutorial!

Published in: Self Improvement, Technology
  • Be the first to comment

  • Be the first to like this

深入淺出RoR

  1. 1. RoR: Ruby on Rails 2009.Apr.14 Eric
  2. 2. Agenda • About RoR • MVC • Implement a simple web post board • Important source code • Conclusion
  3. 3. About RoR • Based on “Ruby Programming Language” • A framework for “Agile Development”
  4. 4. MVC Model-View-Controller
  5. 5. Implement • Before you start the implement, you have to make sure your system environment is readay! • Ruby 1.8.6 • Rails > 2.2 • MySQL >5.0
  6. 6. 1.Create the project > rails post Generating project files
  7. 7. 2. Select Database Type >rails post -d <type> mysql sqlite3 postgreSQL Write the variables to database.yml
  8. 8. 3. Configure a Database ~> cd post post> nano config/database.yml
  9. 9. 4. Create database > rake db:create Connect to database Check the result Create successfully!
  10. 10. 5. Generate Controller > script/generate controller home index Generate controller files automatically
  11. 11. Test the Server > script/server http://127.0.0.1:3000/home/index Text Default Index
  12. 12. 6. Setting the Homepage remove default index Edit config/routes.rb Add this argument
  13. 13. 7. Scaffold script/generate scaffold Post name:string title:string content:text views views including layout models
  14. 14. 8.Migrate > rake db:migrate Check the database Tables of database Fields in table
  15. 15. 9. Done app/views/home/index.html.erb use the “link_to” method New index page After click Add a post
  16. 16. 10.Test Post Successful New Back to list (show) Database Status Edit
  17. 17. Important Source Code
  18. 18. Database Fields Schema Support version control
  19. 19. Interface Index page Show post New post Just using html and erb generate the view
  20. 20. Operate index update show delete create
  21. 21. Conclusion • Really agile • Database independent • The possibility of Ajax • Implement the web service

×