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
140
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
78
What is an API
jwo
0
140
DIY Rails Authentication
jwo
0
170
ActionCable - For Not Another Chat App
jwo
3
1.2k
SlackBot.rb - Create You a Slack Bot
jwo
1
1.1k
react-rails: an isomorphic match made in heaven
jwo
0
1.1k
Docker - next big thing
jwo
0
710
Ruby 2.1 Overview
jwo
0
720
Rails 4: Appetizers
jwo
1
740
Other Decks in Technology
See All in Technology
サービスメッシュ環境における OpenTelemetry 活用 / OpenTelemetry in Service Mesh
k6s4i53rx
2
840
業務で使えるかもしれない…!?GitHub Actions の Tips 集 / CI/CD Test Night #7
ponkio_o
PRO
24
6.9k
「XX試験の環境作ってよ」と言われた時によく使うAWSのソリューションについて
bun913
0
120
生成AIの不確実性と向き合うためのオブジェクト指向設計
tkikuchi1002
2
660
匠MethodとRDRAとICONIXとDDDで実現する一気通貫オブジェクト指向開発
haru860
4
2k
生成AIサービスPanorama AIご説明資料
sdt
0
300
大規模なアジャイル開発の現場と技術負債 / Technical Debt
yoshiitaka
20
4k
既存プロセスからの脱却と変化に適応するために必要なこと
cybozuinsideout
PRO
2
170
Oracle Database で機械学習を始めよう! Oracle Machine Learning
oracle4engineer
PRO
1
140
Azureコストは水道代/The_47th_Tokyo_Jazug
aeonpeople
3
360
技術広報経験0のEMがエンジニアブランディングをはじめてみた
coconala_engineer
1
130
統計的学習理論読み Chapter 2
kmatsui
1
210
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
501
110k
For a Future-Friendly Web
brad_frost
170
8.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.8k
The World Runs on Bad Software
bkeepers
PRO
60
6.6k
Mobile First: as difficult as doing things right
swwweet
215
8.5k
GitHub's CSS Performance
jonrohan
1023
450k
Optimising Largest Contentful Paint
csswizardry
7
2.3k
No one is an island. Learnings from fostering a developers community.
thoeni
14
2k
A Philosophy of Restraint
colly
195
15k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
657
120k
Web development in the modern age
philhawksworth
201
10k
Statistics for Hackers
jakevdp
789
220k
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