Does Ruby on Rails have the equivalent of a Django ModelForm?

I have been using Django for about a year and I think I’ll try Ruby on Rails to see how it compares. In Django, you can create a ModelForm that automatically generates html for the type-based fields in your model. Is there a class that does something similar in Rails? I know scaffolding will create an erb file for my model, but is there any way to do this?

<%= auto_form_for @person %>

Or that?

<%= form_for @person do |f| %>
<% for each @person.fields do | field| %>
<%= auto_field f, field %>
<%end%>
<% end %>

Sorry for my bad ruby ​​code.

+3
source share
2 answers

I found a gem called simple_form that looks like formtastic. This allows you to define these forms:

<%= simple_form_for @user do |f| %>
  <%= f.input :username %>
  <%= f.input :password %>
  <%= f.button :submit %>
<% end %>

, . twitter bootstrap, .

+2

Formtastic Django, , , . , , "" ( ), Formtastic HTML , .

Rails ; , Formtastic.

+2

Source: https://habr.com/ru/post/1791798/


All Articles