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
DVD of Rails
Search
ogom
August 12, 2014
Programming
0
1.9k
DVD of Rails
Detonation Velocity Development
ogom
August 12, 2014
Tweet
Share
More Decks by ogom
See All by ogom
PicoRuby から始めるたのしい電子工作
ogom
0
1.9k
GraphQL Better Errors
ogom
0
370
Osaka RubyKaigi 02
ogom
0
330
Osaka RubyKaigi 01
ogom
0
210
Contributing to GitLab with OSS Gate
ogom
0
590
DojoCon Japan 2017
ogom
0
140
GDStudy Engage
ogom
1
800
Using Immutable.js with React Redux
ogom
0
150
CoderDojo と オープンソース
ogom
2
500
Other Decks in Programming
See All in Programming
CloudflareのChat Agent Starter Kitで簡単!AIチャットボット構築
syumai
2
510
速いWebフレームワークを作る
yusukebe
5
1.7k
AIと私たちの学習の変化を考える - Claude Codeの学習モードを例に
azukiazusa1
11
4.4k
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
110
Azure SRE Agentで運用は楽になるのか?
kkamegawa
0
2.5k
Namespace and Its Future
tagomoris
6
710
2025 年のコーディングエージェントの現在地とエンジニアの仕事の変化について
azukiazusa1
24
12k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
410
AWS発のAIエディタKiroを使ってみた
iriikeita
1
190
HTMLの品質ってなんだっけ? “HTMLクライテリア”の設計と実践
unachang113
4
2.9k
基礎から学ぶ大画面対応(Learning Large-Screen Support from the Ground Up)
tomoya0x00
0
3.3k
「手軽で便利」に潜む罠。 Popover API を WCAG 2.2の視点で安全に使うには
taitotnk
0
870
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Code Review Best Practice
trishagee
71
19k
Scaling GitHub
holman
463
140k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
For a Future-Friendly Web
brad_frost
180
9.9k
How to Think Like a Performance Engineer
csswizardry
26
1.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.9k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
850
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Unsuck your backbone
ammeep
671
58k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Transcript
DVD of Rails 63rd RubyKansai Takashi Ogomori
Detonation Velocity Development Ruby on Rails Demonstration of Live Coding.
Let's Make the Doorkeeper with Rails. 2/18
Rails New Rails Server rails new doorswatch cd doorswatch/ rails
server 3/18
Welcome Welcome Controller Root Route rails generate controller welcome index
cat << __EOS__ > ./config/routes.rb Rails.application.routes.draw do root 'welcome#index' end __EOS__ 4/18
Bootstrap Gemfile Bundler gem 'therubyracer', platforms: :ruby echo "gem 'twitter-bootswatch-rails'"
>> Gemfile echo "gem 'twitter-bootswatch-rails-helpers'" >> Gemfile bundle 5/18
Bootswatch Theme Layout rails generate bootswatch:install yeti rails generate bootswatch:import
yeti --force rails generate bootswatch:layout yeti cat << __EOS__ > ./app/controllers/welcome_controller.rb class WelcomeController < ApplicationController layout 'yeti' def index end end __EOS__ 6/18
Hello, world! Container cat << __EOS__ > ./app/views/welcome/index.html.erb <div class="container">
<div class="page-header" id="banner"> <div class="row"> <div class="col-lg-8 col-md-7 col-sm-6"> <h1>Welcome</h1> </div> </div> </div> </div> __EOS__ 7/18
Domain Model 8/18
Resources Group User rails generate scaffold group name:string rake db:migrate
rails generate bootswatch:themed Groups --force rails generate scaffold user name:string email:string rake db:migrate rails generate bootswatch:themed Users --force 9/18
Navbar Partial cat << __EOS__ > ./app/views/layouts/_navbar.html.erb <ul class="nav navbar-nav">
<%= content_tag(:li, class: controller_name == 'groups' ? :active : nil) do %> <% link_to :Groups, groups_path %> <% end %> <%= content_tag(:li, class: controller_name == 'users' ? :active : nil) do %> <% link_to :Users, users_path %> <% end %> </ul> __EOS__ 10/18
References Member Groups Route rails generate scaffold member group:references user:references
rake db:migrate rails generate bootswatch:themed Members --force resources :groups do resources :members end 11/18
Link Groups Show Members Index <%= link_to t('.members', :default =>
t("helpers.links.members")), group_members_path(@group), :class => 'btn' %> <%= link_to t('.new', :default => t("helpers.links.new")), new_group_member_path, :class => 'btn btn-primary' %> 12/18
Model Group User class Group < ActiveRecord::Base has_many :members has_many
:users, through: :members end class User < ActiveRecord::Base has_many :members has_many :groups, through: :members end 13/18
Controller Before Action Create Private before_action :set_group, only: [:new, :create]
@member = @group.members.new(member_params) def set_group @group = Group.find(params[:group_id]) end 14/18
View Form Show <%= form_for [@group, @member], :html => {
:class => 'form-horizontal' } do |f| %> <div class="form-group"> <%= f.label :user_id, :class => 'control-label' %> <%= f.collection_select :user_id, User.all, :id, :name, {prompt: "Select for a user"}, :class => 'form-control' %> </div> <dl class="dl-horizontal"> <dt><strong><%= model_class.human_attribute_name(:group_id) %>:</strong></dt> <dd><%= @member.group.name %></dd> <dt><strong><%= model_class.human_attribute_name(:user_id) %>:</strong></dt> <dd><%= @member.user.name %></dd> </dl> 15/18
Octicons Bundler Plus echo "gem 'octicons-rails'" >> Gemfile bundle <%=
link_to new_group_member_path, :class => 'btn btn-primary' do %> <span class="octicon octicon-plus"></span> <span><%= t('.new', :default => t("helpers.links.new")) %></span> <% end %> 16/18
Gravatar Bundler Image Tag echo "gem 'gravatar_image_tag'" >> Gemfile bundle
<td> <%= gravatar_image_tag(member.user.email, alt: member.user.name, gravatar: { size: 28 }) %> <%= member.user.name %> </td> 17/18
Thank You! ♥ ɿ? 18/18