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
180
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
140
What is an API
jwo
0
200
DIY Rails Authentication
jwo
0
220
ActionCable - For Not Another Chat App
jwo
3
1.8k
SlackBot.rb - Create You a Slack Bot
jwo
1
1.4k
react-rails: an isomorphic match made in heaven
jwo
0
1.4k
Docker - next big thing
jwo
0
990
Ruby 2.1 Overview
jwo
0
1k
Rails 4: Appetizers
jwo
1
1k
Other Decks in Technology
See All in Technology
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
【Oracle Cloud ウェビナー】[Oracle AI Database + AWS] Oracle Database@AWSで広がるクラウドの新たな選択肢とAI時代のデータ戦略
oracle4engineer
PRO
1
130
Amazon S3 Vectorsを使って資格勉強用AIエージェントを構築してみた
usanchuu
3
450
FinTech SREのAWSサービス活用/Leveraging AWS Services in FinTech SRE
maaaato
0
130
GSIが複数キー対応したことで、俺達はいったい何が嬉しいのか?
smt7174
3
150
超初心者からでも大丈夫!オープンソース半導体の楽しみ方〜今こそ!オレオレチップをつくろう〜
keropiyo
0
110
Greatest Disaster Hits in Web Performance
guaca
0
210
15 years with Rails and DDD (AI Edition)
andrzejkrzywda
0
190
Data Hubグループ 紹介資料
sansan33
PRO
0
2.7k
OCI Database Management サービス詳細
oracle4engineer
PRO
1
7.4k
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
13k
AI駆動PjMの理想像 と現在地 -実践例を添えて-
masahiro_okamura
1
110
Featured
See All Featured
Google's AI Overviews - The New Search
badams
0
900
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Evolving SEO for Evolving Search Engines
ryanjones
0
120
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
410
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
320
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Unsuck your backbone
ammeep
671
58k
Chasing Engaging Ingredients in Design
codingconduct
0
110
Java REST API Framework Comparison - PWX 2021
mraible
34
9.1k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.6k
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