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
79
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
730
Ruby 2.1 Overview
jwo
0
730
Rails 4: Appetizers
jwo
1
750
Other Decks in Technology
See All in Technology
Vertex AI を中心に 生成AIのアップデートを共有します
kaz1437
0
300
長期運用プロジェクトでのMySQLからTiDB移行の検証
colopl
2
850
ゼロから始めるVue.jsコミュニティ貢献 / first-vuejs-community-contribution-link-and-motivation
lmi
1
120
Cracking the KubeCon CfP
inductor
2
240
Tellus の衛星データを見てみよう #mf_fukuoka
kongmingstrap
0
180
自己改善からチームを動かす! 「セルフエンジニアリングマネージャー」のすゝめ
shoota
6
430
推しは推せるときに推せ! プロダクトにフィードバックしていこう
nakasho
0
300
ServiceNow Knowledge 24の歩き方 EYストラテジー・アンド・コンサルティング
manarobot
0
190
よく聞くけど使ったことないソフトウェアNo.1 KafkaとSnowflake
foursue
4
350
プロンプトエンジニアリングでがんばらない-Agentic Workflow へ-近藤憲児
kenjikondobai
2
140
「スニダン」開発組織の構造に込めた意図 ~組織作りはパッションや政治ではない!~
rinchsan
3
550
私が trocco を推す理由
__allllllllez__
1
220
Featured
See All Featured
Atom: Resistance is Futile
akmur
259
25k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
2
1.3k
Docker and Python
trallard
34
2.7k
YesSQL, Process and Tooling at Scale
rocio
164
13k
A designer walks into a library…
pauljervisheath
200
23k
10 Git Anti Patterns You Should be Aware of
lemiorhan
648
58k
Build The Right Thing And Hit Your Dates
maggiecrowley
24
2k
The Illustrated Children's Guide to Kubernetes
chrisshort
31
46k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
16
2.6k
Large-scale JavaScript Application Architecture
addyosmani
504
110k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
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