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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Dôn Đinh
June 24, 2015
Programming
0
39
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
Tweet
Share
Other Decks in Programming
See All in Programming
株式会社 Sun terras カンパニーデック
sunterras
0
2.1k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
230
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
140
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
2
110
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
110
ポーリング処理廃止によるイベント駆動アーキテクチャへの移行
seitarof
3
1k
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
430
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
3
770
New in Go 1.26 Implementing go fix in product development
sunecosuri
0
420
エンジニアの「手元の自動化」を加速するn8n 2026.02.27
symy2co
0
140
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
1
130
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
370
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Practical Orchestrator
shlominoach
191
11k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
170
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.4k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.4k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Fireside Chat
paigeccino
42
3.8k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
70
Building an army of robots
kneath
306
46k
Building the Perfect Custom Keyboard
takai
2
710
WCS-LA-2024
lcolladotor
0
480
Six Lessons from altMBA
skipperchong
29
4.2k
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!