Rails解説セミナー 第14章

Preview:

Citation preview

14 #Rails

http://railstutorial.jp/

Rails

by YassLab

Slideshare

http://www.slideshare.net/yasulab/presentations

Cloud9

1. 2. URL 3.

https://ide.c9.io/yasulab/rails-tutorial

https://rails-tutorial-yasulab.c9users.io/

URL “Collaborate” → “Group Chat”

! :)

Ready?

!

14 #Rails

http://railstutorial.jp/

Rails

by YassLab

1. Micropost (cf. 2, 4, 6 ) User Micropost − User has_many Microposts − Micropost belongs_to User

2. Micropost (cf. 7, 8, 9 )

3. Micropost (cf. 10 )

4. Micropost

✅ 11 📨 🔒

✅ 12 📨 🔓

✅ 13 📮 🐤

14 👤 👤

: http://bit.ly/sample_app_4e

1. Relationship

• User

• Relationship followed/follower

• follow

2. Ajax follow/unfollow UI

3. follow feed

4. / /

[Follow]

[Unfollow] followers ++

following ++

14 Relationship

http://railstutorial.jp/

Rails

by YassLab

1. ? 2. ? 3. ?

Micropost ?

: !

(relationship)

“#{ }_id”

Relationship• Relationship

$ rails generate model Relationship follower_id:integer followed_id:integer

👇

👇

( )

User/Relationship

• User/Relationship

( ) 👆

👇

TDD

• ID

• has_many through

• has_many belongs_to

• (TDD)

• (RED → GREEN) follow unfollow following?

“#{ }s”

( )

• has_many through ( )

• passive_relationships ( : ) vs. active_relationships ( : )

• has_many belongs_to

• ✅

14 [Follow] Web

http://railstutorial.jp/

Rails

by YassLab

[Follow] Web

• 🌱 follow

• 🔧 following/followers

• 🔧 Follow/Unfollow

(root_url)

👈

shared/ stats

/users/:id

👈

shared/ stats

• Follow

• / (form)

[Follow] /users/:id

👆 users/follow

👆 users/unfollow

👇 users/follow_form

👥 [Following] [Followers]

• 🔍

• ✅ TDD

• 🔧

/users/:id/following

/users/:id/followers

: ? 🤔 /users/:id/following

: ? 🤔 /users/:id/followers

👥 [Following] [Followers]

• 🔍

• ✅ TDD

• 🔧

• create/destroy ( )

• form (Ajax)

[Follow] ( ) /users/:id

[Follow] ( ) /users/:id

14

http://railstutorial.jp/

Rails

by YassLab

+

following

+

current_user following

microposts

+

current_user.microposts + current_user.following …

microposts

microposts

+

current_user.microposts + current_user.following .map do {|u| u.microposts }

microposts

+

current_user.microposts + current_user.following .map(&:microposts)

microposts

+

current_user.microposts + current_user.following .map(&:microposts)

microposts

1 ( )

( )

• :

1. followed_users .

2. .

3. follow .

• SQL

1. Relationship

• User

• Relationship followed/follower

• follow

2. Ajax follow/unfollow UI

3. follow feed

4. / /

Rails! ( )

: Iriguti (“ ” )

: SharePla ( )

: ( )

Rails JavaScript http://railsguides.jp/working_with_javascript_in_rails.html

Active Support http://railsguides.jp/active_support_core_extensions.html

Rails (I18n) APIhttp://railsguides.jp/i18n.html

Rails http://railsguides.jp/debugging_rails_applications.html

Ruby on Rails http://railsguides.jp/contributing_to_ruby_on_rails.html

!( !)

!

Rails !: 2016 11 ( 30 ) : Ruby on Rails (Rails 5.0 )http://railstutorial.jp/seminars#record

RoR http://coedo-rails.doorkeeper.jp/

‘ ’※

• :) :

http://railstutorial.jp/seminars

• , !

• ! && …!! ㊗ 👏✨

14 #Rails

http://railstutorial.jp/

Rails

by YassLab

Recommended