Skip to content

Instantly share code, notes, and snippets.

@jlebrech
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlebrech/8863055 to your computer and use it in GitHub Desktop.
Save jlebrech/8863055 to your computer and use it in GitHub Desktop.
RealForm
<% @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 %>
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
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