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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
Claude Codeログ基盤の構築
giginet
PRO
7
3.8k
Java 21/25 Virtual Threads 소개
debop
0
310
How to stabilize UI tests using XCTest
akkeylab
0
150
RailsのValidatesをSwift Macrosで再現してみた
hokuron
0
140
Tamach-sre-3_ANDPAD-shimaison93
mane12yurks38
0
220
Nuxt Server Components
wattanx
0
230
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
380
Codex の「自走力」を高める
yorifuji
0
1.3k
CS教育のDX AIによる育成の効率化
niftycorp
PRO
0
170
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
750
条件判定に名前、つけてますか? #phperkaigi #c
77web
2
900
夢の無限スパゲッティ製造機 -実装篇- #phpstudy
o0h
PRO
0
180
Featured
See All Featured
Being A Developer After 40
akosma
91
590k
Context Engineering - Making Every Token Count
addyosmani
9
790
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
The Curious Case for Waylosing
cassininazir
0
280
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
The SEO identity crisis: Don't let AI make you average
varn
0
430
4 Signs Your Business is Dying
shpigford
187
22k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Site-Speed That Sticks
csswizardry
13
1.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
WENDY [Excerpt]
tessaabrams
9
37k
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!