Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Tiếp tục làm tutorial của Rails Girls
Search
Dôn Đinh
June 24, 2015
Programming
43
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Tiếp tục làm tutorial của Rails Girls
Tạo một comment theo mẫu và thiết lập Devise gem trong
application.
Dôn Đinh
June 24, 2015
Other Decks in Programming
See All in Programming
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
410
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
670
Go 1.27からのGODEBUG / Go 1.27 リリースパーティ #go127party
mazrean
0
320
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
360
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
0
380
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
460
一参加者から『中の人』へ 〜全通PHPerがブースに立って学んだ、カンファレンスを100倍楽しむコツ〜
wp_daisuke
0
120
AIの中の人になってみる
htkym
0
170
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
270
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
500
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
0
240
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
140
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
570
WENDY [Excerpt]
tessaabrams
12
39k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Technical Leadership for Architectural Decision Making
baasie
3
560
Done Done
chrislema
186
16k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Code Reviewing Like a Champion
maltzj
528
40k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
380
New Earth Scene 8
popppiees
3
2.5k
Transcript
Tiếp tục làm tutorial của Rails Girls Dôn Đinh
Tạo một comment theo mẫu Rails g scaffold comment user_name:string
body:text idea_id:integer Tạo một migration file trong database: rake db:migrate
Thêm relations đến models class Idea < ActiveRecord::Base has_many :comments
class Comment < ActiveRecord::Base belongs_to :idea
Hướng dẫn cách tạo comment theo form <h3>Comments</h3> <% @comments.each
do |comment| %> <div> <strong><%= comment.user_name %></strong> <br /> <p><%= comment.body %></p> <p><%= link_to 'Delete', comment_path(comment), method: :delete, data: { confirm: 'Are you sure?' } %></p> </div> <% end %> <%= render 'comments/form' %>
Tạo xác nhận đăng nhập với Devise Thêm devise gem
vào gem file: gem 'devise' Chạy lệnh để cài the gem: bundle install
Thiết lập Devise gem trong application rails g devise:install
Cấu hình devise Open up config/environments/development.rb and add this line
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } Open up app/views/layouts/application.html.erb and add: <% if notice %> <p class="alert alert-success"><%= notice %></p> <% end %> <% if alert %> <p class="alert alert-danger"><%= alert %></p> <% end %>
Thiết lập User model Tạo user model: Sau đó tạo
user đầu tiên rails g devise user rake db:migrate
Tạo sign-up và login link <p class="navbar-text pull-right"> <% if
user_signed_in? %> Logged in as <strong><%= current_user.email %></strong>. <%= link_to 'Edit profile', edit_user_registration_path, :class => 'navbar-link' %> | <%= link_to "Logout", destroy_user_session_path, method: :delete, :class => 'navbar-link' % > <% else %> <%= link_to "Sign up", new_user_registration_path, :class => 'navbar-link' %> | <%= link_to "Login", new_user_session_path, :class => 'navbar-link' %> <% end %>
Ruby Girls Việt Nam Thank you!