Last active
August 29, 2015 13:56
-
-
Save jlebrech/8863055 to your computer and use it in GitHub Desktop.
RealForm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @my_form.render do |f| # custom form %> | |
<div class="firstname"><%= f.firstname # maybe options are possible here %></div> | |
<div class="text"><%= f.text %></div> | |
<% end %> | |
<%= @my_form.render # no customization %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class MyForm < RealForm | |
text_area :text, size: 100, label: "Some text", class: "funky class", validate: is_blah_blah | |
input :firstname | |
password :password, id: "the password" | |
def is_blah_blah | |
... | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def edit | |
@my_form = MyForm.new() | |
end | |
def update | |
@my_form = MyForm.new(params) | |
if @my_form.valid? | |
@mc_guffin.update_parameters(@my_form.to_hash) | |
else | |
flash.now @my_form.errors | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment