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
0
35
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
詳しくない分野でのVibe Codingで困ったことと学び/vibe-coding-in-unfamiliar-area
shibayu36
3
4.9k
Serena MCPのすすめ
wadakatu
4
980
NixOS + Kubernetesで構築する自宅サーバーのすべて
ichi_h3
0
610
dynamic!
moro
10
7.3k
CSC305 Lecture 04
javiergs
PRO
0
260
Software Architecture
hschwentner
6
2.3k
CSC509 Lecture 05
javiergs
PRO
0
300
GitHub Actions × AWS OIDC連携の仕組みと経緯を理解する
ota1022
0
250
止められない医療アプリ、そっと Swift 6 へ
medley
1
160
Pull-Requestの内容を1クリックで動作確認可能にするワークフロー
natmark
2
490
Cloudflare AgentsとAI SDKでAIエージェントを作ってみた
briete
0
140
株式会社 Sun terras カンパニーデック
sunterras
0
280
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
4 Signs Your Business is Dying
shpigford
185
22k
How GitHub (no longer) Works
holman
315
140k
How to Think Like a Performance Engineer
csswizardry
27
2k
Into the Great Unknown - MozCon
thekraken
40
2.1k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Designing for Performance
lara
610
69k
Faster Mobile Websites
deanohume
310
31k
Context Engineering - Making Every Token Count
addyosmani
5
220
Music & Morning Musume
bryan
46
6.8k
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!