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
Rails Essentials: simple_form
Search
Jesse Wolgamott
October 10, 2012
Technology
1
160
Rails Essentials: simple_form
Houston Ruby Brigade appetizer to simple_form (rails form DSL)
Jesse Wolgamott
October 10, 2012
Tweet
Share
More Decks by Jesse Wolgamott
See All by Jesse Wolgamott
React vs React-Native
jwo
0
98
What is an API
jwo
0
170
DIY Rails Authentication
jwo
0
180
ActionCable - For Not Another Chat App
jwo
3
1.4k
SlackBot.rb - Create You a Slack Bot
jwo
1
1.2k
react-rails: an isomorphic match made in heaven
jwo
0
1.2k
Docker - next big thing
jwo
0
840
Ruby 2.1 Overview
jwo
0
850
Rails 4: Appetizers
jwo
1
860
Other Decks in Technology
See All in Technology
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
240
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
120
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
280
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
130
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
170
OCI Network Firewall 概要
oracle4engineer
PRO
0
4.1k
Taming you application's environments
salaboy
0
180
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
370
Lambdaと地方とコミュニティ
miu_crescent
2
370
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
0
110
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
150
Featured
See All Featured
Bash Introduction
62gerente
608
210k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
BBQ
matthewcrist
85
9.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Agile that works and the tools we love
rasmusluckow
327
21k
How GitHub (no longer) Works
holman
310
140k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Transcript
SIMPLE FORM Rails Essentials: @jwo
gem “simple_form” bundle rails g simple_form:install By Platformatec (same cats
as Devise)
rails g scaffold post title body publish_on:date featured:boolean Why is
this needed? <%= simple_form_for(@post) do |f| %> <%= f.error_notification %> <div class="form-inputs"> <%= f.input :title %> <%= f.input :body %> <%= f.input :publish_on %> <%= f.input :featured %> </div> <div class="form-actions"> <%= f.button :submit %> </div> <% end %>
As Compared to <%= form_for(@post) do |f| %> <% if
@post.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2> <ul> <% @post.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :title %><br /> <%= f.text_field :title %> </div> <div class="field"> <%= f.label :body %><br /> <%= f.text_field :body %> </div> <div class="field"> <%= f.label :publish_on %><br /> <%= f.date_select :publish_on %> </div> <div class="field"> <%= f.label :featured %><br /> <%= f.check_box :featured %> </div> <div class="actions"> <%= f.submit %> </div> <% end %>
Let’s see that again <%= simple_form_for(@post) do |f| %> <%=
f.error_notification %> <div class="form-inputs"> <%= f.input :title %> <%= f.input :body %> <%= f.input :publish_on %> <%= f.input :featured %> </div> <div class="form-actions"> <%= f.button :submit %> </div> <% end %>
It’s Just a Wrapper All form_helpers in Rails apply select,
collection_select, date_select You can pass to the HTML of the form or the input
Why over Formtastic? Formtastic had a strong opinion on form
markup created You can define what markup to use with your CSS Twitter Bootstrap, Zurb Foundation, ALL CAN BE YOURS
GUESS WHAT
Associations has many throughs are now SIMPLE. f.association :categories, as:
:check_boxes
Bootstrap Integration Yes, it does this nicely And there’s a
bootstrap picker. demo (github.com/houstonruby/rails_essentials/simple_form