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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Dôn Đinh
June 24, 2015
Programming
39
0
Share
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
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
580
どんと来い、データベース信頼性エンジニアリング / Introduction to DBRE
nnaka2992
1
350
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
530
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
130
How to stabilize UI tests using XCTest
akkeylab
0
150
AI-DLC 入門 〜AIコーディングの本質は「コード」ではなく「構造」〜 / Introduction to AI-DLC: The Essence of AI Coding Is Not “Code” but “Structure”
seike460
PRO
0
140
AI活用のコスパを最大化する方法
ochtum
0
360
おれのAgentic Coding 2026/03
tsukasagr
1
120
Claude Codeログ基盤の構築
giginet
PRO
7
3.8k
条件判定に名前、つけてますか? #phperkaigi #c
77web
2
900
Symfonyの特性(設計思想)を手軽に活かす特性(trait)
ickx
0
110
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
16
3.5k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
698
190k
SEO for Brand Visibility & Recognition
aleyda
0
4.4k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.9k
Building Applications with DynamoDB
mza
96
7k
A Soul's Torment
seathinner
5
2.6k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
300
Music & Morning Musume
bryan
47
7.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
64
54k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
320
The Cult of Friendly URLs
andyhume
79
6.8k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.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!