CSC/ECE 517 Spring 2015/ch1b 22 SF

From Expertiza_Wiki
Jump to navigation Jump to search

Simple Form

Simple form is a Rails gem used for easily creating Rails forms.

The topic write up for this page can be found here.

1 Introduction
    1.1 Background
2 Getting Start
    2.1 Installation
    2.2 Bootstrap
    2.3 Usage
3 Example applications

4 Other Rails forms framework
    4.1 Formtastic
5 Conclusion
6 References

Introduction

Background

Rails forms made easy
Simple Form aims to be as flexible as possible while helping you with powerful components to create your forms . The basic goal of Simple Form is to not touch your way of defining the layout, letting you find the better design for your eyes. Most of the DSL was inherited from Formtastic.

Getting Start

Installation

You can use the following code to install simple_form:

gem install simple_form

But I recommend you to use the following way:
Add the following code to your Gemfile:

gem 'simple_form'

And in your Rails application root directory, run the following command:

bundle install

Run the following code to generate the simple_form into your app:

rails generate simple_form install

Work with Bootstrap

Similar to H5BP and 960 Grid System, Bootstrap is a simple and very popular front-end framework.

With the following code while installing Simple Form, you can integrate Simple Form to Bootstrap

# rails generate simple_form:install --bootstrap

You have to be sure that you added a copy of the Bootstrap assets on your application.

For more information see the generator output, out example application code and the live example app.

References

  1. https://github.com/plataformatec/simple_form
  2. http://getbootstrap.com/
  3. https://github.com/justinfrench/formtastic