getting started with rails (4)

9
Getting Started (4) 2014. 12. 9 Lucius Choi(@luciuschoi) ROR Lab. Season 4, 76th Biweekly Lecture

Upload: ror-lab

Post on 13-Jul-2015

472 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Getting Started with Rails (4)

Getting����������� ������������������  Started����������� ������������������  (4)

2014. 12. 9 Lucius Choi(@luciuschoi)

ROR Lab. Season 4, 76th Biweekly Lecture

Page 2: Getting Started with Rails (4)

MVCrequest(URI)

routing

response

controller action

Cmodel

M

viewV

database

Page 3: Getting Started with Rails (4)

“Article”����������� ������������������  Model

articles

title string text text

has_many :comments, dependent: :destroy

Page 4: Getting Started with Rails (4)

“Comment”����������� ������������������  Model

comments

commenter string body text article_id integer

belongs_to :article

Page 5: Getting Started with Rails (4)

Nested����������� ������������������  Routing$ rake routes Prefix Verb URI Pattern Controller#Action article_comments GET /articles/:article_id/comments(.:format) comments#index POST /articles/:article_id/comments(.:format) comments#create new_article_comment GET /articles/:article_id/comments/new(.:format) comments#newedit_article_comment GET /articles/:article_id/comments/:id/edit(.:format) comments#edit article_comment GET /articles/:article_id/comments/:id(.:format) comments#show PATCH /articles/:article_id/comments/:id(.:format) comments#update PUT /articles/:article_id/comments/:id(.:format) comments#update DELETE /articles/:article_id/comments/:id(.:format) comments#destroy articles GET /articles(.:format) articles#index POST /articles(.:format) articles#create new_article GET /articles/new(.:format) articles#new edit_article GET /articles/:id/edit(.:format) articles#edit article GET /articles/:id(.:format) articles#show PATCH /articles/:id(.:format) articles#update PUT /articles/:id(.:format) articles#update DELETE /articles/:id(.:format) articles#destroy root GET / welcome#index welcome_index GET /welcome/index(.:format) welcome#index

Page 6: Getting Started with Rails (4)

Partial����������� ������������������  Template

• _template_name.html.erb

• using instance variables in parent template file

• “form” partial template : _form.html.erb

Page 7: Getting Started with Rails (4)

HTTP����������� ������������������  Basic����������� ������������������  Auth.

• http_basic_authenticate_with( name, password)

Page 8: Getting Started with Rails (4)

Live����������� ������������������  Demo

Page 9: Getting Started with Rails (4)

����������� ������������������  감사합니다.