Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Advantages of "Simple Form."

Hi,

I'm making a Ruby on Rails app and am wondering what advantages there are to using "Simple Form" as opposed to the regular RoR form.

Thank you for your advice!

-Chase

4 Answers

So one thing I know it does it not need to add the label element all the time, so instead of:

<%= f.label :content %>
<%= f.text_field :content %>

You just have to do

<%= f.input :content %>

And based on the type for :content, simple_form guesses if you want a text_field or text_area and adds the label. For a basic app, that can be great.

I ran into problems when I needed more complex forms. I ended up spending more time trying to hack simple_form than just using regular rails form helpers.

I actually removed simple form all together. It forced me to really learn rails form helpers. So if you just need some quick forms, simple_form may be what you want. If you want to learn what's really going on, I'd study up on the form_helper section in the rails documentation and play around.

You can have simple_form installed and still use regular forms. Just change from simple_form(@model) to form_for(@model).

I highly suggest NOT using simple form. I dont remember the exact cases that caused me headaches but it's really had to customize simple_form labels, fields etc. Overall it does more damage than good in my opinion.

Thank you both!

If you're a beginner, I too suggest you do not use the simple_form gem unless you find a tutorial going through its usage and compares it extensively to the regular form helpers Rails provide you.

You should know how to use the Rails regular form helpers, just as you should know how to eventually use Minitest if you want to ever seriously contribute to Rails itself.

Using simple_form instead of the regular Rails helpers isn't as severe as such a choice, but it's not as simple as replacing .erb templates with .haml files either.