test/dummy/app/controllers/demo_controller.rb
# Formalizer's generated form has no authenticity_token field. 
# This field can (and should) be used, either manually or automatically,
# by replacing the generated <form> tag with Rails form_tag or form_for(active_record model) helper.
# To skip authenticity protection in this controller, uncomment the following line at your own risk:
# protect_from_forgery :only => [:index]
Formalizer's generated form has no authenticity_token field.
This field can (and should) be used, either manually or automatically,
by replacing the generated  tag with Rails form_tag or form_for(active_record model) helper.
To skip authenticity protection in this controller, uncomment the following line at your own risk:
protect_from_forgery :only => [:index]
Formalizer ' s generated form has no authenticity_token field . This field can ( and should ) be used either manually or automatically by replacing the generated tag with Rails form_tag or form_for ( active_record model ) helper . To skip authenticity protection in this controller uncomment the following line at your own risk : protect_from_forgery : only = > [ : index ]
def index
    @page = 'demo'
    fill_form and return if request.method == 'POST'
    fill_form = Formalizer.new.generate_fields_form(I18n.locale, '', 'nda')
    fill_form_html = Nokogiri::HTML(fill_form)
    auth_token_field = Nokogiri::XML::Node.new('input', fill_form_html)
    fill_form_html.css('div').each{|div| div['class'] = 'form-group'}
    fill_form_html.css('label').each{|label| label['class'] = 'col-lg-4 control-label'}
    fill_form_html.css('div.form-group input:not([type="reset"]):not([type="submit"])').wrap('<div class="col-lg-8">')
    fill_form_html.css('div.form-group select').wrap('<div class="col-lg-8">')
    fill_form_html.css('div.form-group input').each{|input| input['class'] = 'form-control'}
    fill_form_html.css('div.form-group select').each{|select| select['class'] = 'form-control'}
    fill_form_html.css('input[type="reset"]').each{|input| input['class'] = 'btn btn-default'}
    fill_form_html.css('input[type="submit"]').each{|input| input['class'] = 'btn btn-primary'}
    fill_form_html.css('div.form-group:last-child').wrap('<div class="form-buttons form-group">')
    fill_form_html.at_css('div.form-buttons > div')['class'] = 'col-lg-8 col-lg-offset-2'
    form_tag = fill_form_html.at_css('form')
    form_tag['class'] = 'form-horizontal'
    auth_token_field = Nokogiri::XML::Node.new('input', fill_form_html)
    auth_token_field['type'] = 'hidden'
    auth_token_field['name'] = 'authenticity_token'
    auth_token_field['value'] = form_authenticity_token
    auth_token_field.parent = form_tag
    @fill_details = fill_form_html.at_css('form').to_s
  end
def index @page = 'demo' fill_form and return if request . method == 'POST' fill_form = Formalizer . new . generate_fields_form ( I18n . locale , '' , 'nda' ) fill_form_html = Nokogiri :: HTML ( fill_form ) auth_token_field = Nokogiri :: XML :: Node . new ( 'input' , fill_form_html ) fill_form_html . css ( 'div' ) . each { | div | div [ 'class' ] = 'form-group' } fill_form_html . css ( 'label' ) . each { | label | label [ 'class' ] = 'col-lg-4 control-label' } fill_form_html . css ( 'div.form-group input:not([type="reset"]):not([type="submit"])' ) . wrap ( '<div class="col-lg-8">' ) fill_form_html . css ( 'div.form-group select' ) . wrap ( '<div class="col-lg-8">' ) fill_form_html . css ( 'div.form-group input' ) . each { | input | input [ 'class' ] = 'form-control' } fill_form_html . css ( 'div.form-group select' ) . each { | select | select [ 'class' ] = 'form-control' } fill_form_html . css ( 'input[type="reset"]' ) . each { | input | input [ 'class' ] = 'btn btn-default' } fill_form_html . css ( 'input[type="submit"]' ) . each { | input | input [ 'class' ] = 'btn btn-primary' } fill_form_html . css ( 'div.form-group:last-child' ) . wrap ( '<div class="form-buttons form-group">' ) fill_form_html . at_css ( 'div.form-buttons > div' ) [ 'class' ] = 'col-lg-8 col-lg-offset-2' form_tag = fill_form_html . at_css ( 'form' ) form_tag [ 'class' ] = 'form-horizontal' auth_token_field = Nokogiri :: XML :: Node . new ( 'input' , fill_form_html ) auth_token_field [ 'type' ] = 'hidden' auth_token_field [ 'name' ] = 'authenticity_token' auth_token_field [ 'value' ] = form_authenticity_token auth_token_field . parent = form_tag @fill_details = fill_form_html . at_css ( 'form' ) . to_s end
Formalizer's generated form has no authenticity_token field.
Formalizer ' s generated form has no authenticity_token field .
# deault root view # navbar current view: # the form is submitted to the same page, handling the POST method first: # Letting Formalizer generate a user input form # We limit fields only to 'nda' tag. Other config tags relate to unit tests, # and are not relevant to the demo's nda form # The generated form is ready to use as is, but we're spicing it up a bit with Bootswatch classes: # Adding authenticity token. The following lines can be commented out if # the protect_from_forgery line is uncommented (see comments at the top) # Finalizing and wrapping the form for view