38. Restful (2)
HTTP METHODS SERVICE METHODS
POST CREATE
POST + /accounts/ Create an account record
GET READ
GET + /accounts/1 Show an account record which id = 1
PUT UPDATE
PUT + /accounts/1 Update an account record which id = 1
DELETE DELETE
DELETE + /accounts/1 Delete an account record which id = 1
43. Action & View – index (3)
-RAILS_ROOT/app/views/accounts/index.html.erb
- http://localhost:3000/accounts
44. URL Helpers
Methods
GET POST PUT DELETE
Helpers
/accounts/1 /accounts/1 /accounts/1
account_path(@account) show update delete
/accounts /accounts
accounts_path index create
/accounts/1/edit
edit_event_path(@account) edit
/accounts/new
new_events_path
new
50. Why You Need Unit Test
• 更容易修改或者改善你的程式碼。
• 更容易與其他系統整合。
• 測試程式碼就是你的文件(的一部分)。
• 你在寫測試程式時,你就是在設計你的目
的程式。(Writing tests before writing the
code being tested.)
• Rails社群提供了很好的工具讓你進行Unit
Test。
51. RSpec plugin
• RSpec 官網: http://rspec.inof
• Install RSpec, Rspec-rails on Rails 2.3.x
– gem install rspec rspec-rails
• Generate RSpec framework for your project