gem 'simple_form'
run bundle for downloading the Gem
bundle install
Deploy the gem:
rails g simple_form:install
This creates some files under your project
create config/initializers/simple_form.rb exist config/locales create config/locales/simple_form.en.yml create lib/templates/erb/scaffold/_form.html.erb
Following the previous sample of books, these are the only lines you need for your _from.html.erb under app/views/books
<%= simple_form_for(@book) do |f| %>
<%= f.input :name %><br />
<%= f.association :status %><br />
<%= f.button :submit %><br />
<% end %>
Notices that we use simple_form_for instead form_for and just one line for each component. simple, hun?
Check out the video from railcast
No comments:
Post a Comment