Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Tiếp tục làm tutorial của Rails Girls
Search
Dôn Đinh
June 24, 2015
Programming
49
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
Transcript
10 slides
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!
Other Decks in Programming
See All in Programming
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
180
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
240
手の動かし方がわからなかった私が個人開発者になるまで
usagi0920_pochi
0
350
AI時代のIaC入門 〜なぜインフラをコードで管理したいのか?〜 / Introduction to IaC in the AI Era
akihisaikeda
6
1.6k
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
310
地方こそサーバーレス — 10年続けた、顔が見えるチームで確かな基盤を / Serverless Matters Most in Regional Areas — 10 Years of Building Reliable Foundations with Close-Knit Teams
seike460
PRO
2
520
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
850
将来の標準フォーマッター?ktfmtを深堀る
t45k
1
250
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
280
joyful-journey-spring-boot.pdf
hollycummins
0
130
AppFunctionsの内部実装を紐解く
hiroaki404
1
130
Proxmox x Talos Linux x Terraform で実現するなんかいい感じの Kubernetes クラスタ / A Sleek Kubernetes Cluster Powered by Proxmox, Talos Linux, and Terraform
nnaka2992
0
320
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Utilizing Notion as your number one productivity tool
mfonobong
4
710
Building the Perfect Custom Keyboard
takai
2
970
What the history of the web can teach us about the future of AI
inesmontani
PRO
3
830
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.9k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
630
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
2
540
The untapped power of vector embeddings
frankvandijk
2
2k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.3k