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
40
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
サークル参加から学ぶ、小さな事業の回し方
yuzneri
0
210
ビジネスモデルから紐解く、AI+型駆動開発
hirokiomote
2
520
Structured Concurrency, Scoped Values and Joiners in the JDK 25 26 27
josepaumard
1
160
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
5
730
「OSSがあるなら自作するな」は AI時代も正しいか ── Build vs Adopt の新しい判断基準
kumorn5s
7
2.8k
【ディップ|26年新卒研修資料】OpenAPI/Swagger REST API研修
dip_tech
PRO
0
240
継続的な負荷検証を目指して
pyama86
3
1.2k
Agentic Elixir
whatyouhide
0
460
自動レビューエンジンの実装と運用 ~レビューのない世界へ~
kurukuru1999
1
110
横断組織出身のQAEがインプロセスQAEでつまずいたこと・活かせたこと
ty89
0
160
AI時代になぜ書くのか
mutsumix
0
430
Sans tests, vos agents ne sont pas fiables
nabondance
0
140
Featured
See All Featured
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
200
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
sira's awesome portfolio website redesign presentation
elsirapls
0
250
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.8k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
190
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!