Im stuck in a very simple problem. I am receiving an array of parameters in my view and want to iterate over the values.
This is the print of my params:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"dfOQVuXlQriII3akiGCSuMIf4i2B8c1/OX02nd6Dhy0ZKzHkhiXxlcXKCJAMFHw0vhtNKKVYuLHFo22LGsy6UQ==", "album"=>{"name"=>"asdasd", "photos_media"=>["[{\"id\":\"a245b724845f447eb63dfbaa3fba173669b55fcdf7fb55fb634707ff0c1c\",\"filename\":\"BWT_eUmU.jfif\",\"content_type\":\"image/jpeg\",\"size\":56060},{\"id\":\"1bfb4188a126079f5069c5204f8df1c7169d0464f488385ef1f8d081fcda\",\"filename\":\"drafts.png\",\"content_type\":\"image/png\",\"size\":6029}]"]}, "commit"=>"Save Album"}
My album_params are like this:
def album_params
params.require(:album).permit(:name, photos_media: [])
end
And my form:
<%= form_for #album do |f| %>
<div class="col-9">
<div class="form-group row" >
<div class="col-6">
<label for="">Name:</label>
<%= f.text_field :name %>
</div>
</div>
</div>
<div class="col-9">
<div class="form-group row" >
<div>
<div class="progress" id='progress-bar' style='display:none;'>
<div class="progress-bar progress-bar-striped active" role="progressbar" style="width: 0%"><h6>Loading...</h6>
<span class="sr-only" id='progress-bar-text'></span>
</div>
</div>
</div>
<div class="col-6">
<label for="">Add or drag photos here:</label>
<%= f.attachment_field :photos_media, multiple: true, direct: true, presigned: true %>
</div>
</div>
</div>
How can I iterate over photos_media? If I do a print on it like this:
logger.debug("******SIZE*** #{album_params[:photos_media].size} ")
It says the size is 1. Like a big string.
What im doing wrong?
As Vailisa says, photo_media contains an Array with one element that is a string:
"photos_media"=>["[{\"id\":\"a245b724845f447eb63dfbaa3fba173669b55fcdf7fb55fb634707ff0c1c\",\"filename\":\"BWT_eUmU.jfif\",\"content_type\":\"image/jpeg\",\"size\":56060},{\"id\":\"1bfb4188a126079f5069c5204f8df1c7169d0464f488385ef1f8d081fcda\",\"filename\":\"drafts.png\",\"content_type\":\"image/png\",\"size\":6029}]"]
Specifically, that string is a JSON string.
To parse that on the backend, you can try:
#photo_media_ary = JSON.parse(album_params[:album][:photos_media][0])
Related
I am using loop in nested forms in rails and i wanted to pass object id through render partial form
app/model/contract_booking_attached_trips.rb
class ContractBookingAttachedTrip < ApplicationRecord
has_many :contract_attached_trip_sheets
accepts_nested_attributes_for :contract_attached_trip_sheets ,allow_destroy: true
belongs_to :booking_history
belongs_to :duty_type
belongs_to :vehicle_make
belongs_to :vehicle_category
end
app/model/contract_attached_trip_sheet.rb
class ContractAttachedTripSheet < ApplicationRecord
belongs_to :contract_booking_attached_trip
end
app/controller/contract_booking_attached_trips_controller
def edit
#contract_booking_attached_trip = ContractBookingAttachedTrip.find(params[:id])
booking_history_id = #contract_booking_attached_trip.booking_history_id
#booking_history = BookingHistory.find(booking_history_id)
#booking_trips = #booking_history.transport_plans
#trip_count = #booking_history.transport_plans.count
#contract_booking_attached_trip.contract_attached_trip_sheets.build
end
app/views/ContractBookingAttachedTrips/_form.html.erb
<div class="container-fluid">
<%= form_for(#contract_booking_attached_trip, :html => {class: "form-horizontal",id: "contract_trip_sheet_validate"}) do |f| %>
<div class="card">
<div class="card-header">
<h5 class="panel-title float-left" style="padding-top: 7.5px;">Duty Slip</h5
</div> <!-- /.card header -->
<div class="card-body">
<div class="card">
<div class="card-body" style="margin-bottom: -50px;">
<div class="row">
<div class="col-md-6 col-lg-6 mb-4 mb-lg-4">
<div class="table-responsive ">
<!--Table-->
<table id="dataTable" class="table table-borderless table-sm" cellspacing="0">
<!--Table body-->
<tbody>
<tr>
<th>Customer</th>
<th><b><%= User.find(#contract_booking_attached_trip.booking_history.try(:user_id)).try(:username) %></b></th>
</tr>
</tbody>
<!--Table body-->
</table>
<!--Table-->
</div> <!-- table -->
</div>
<div class="col-md-6 col-lg-6 mb-4 mb-lg-4">
<div class="table-responsive ">
<!--Table-->
</div> <!-- table -->
</div>
</div><!-- row1 -->
</div> <!-- inner card body -->
</div> <!-- inner card -->
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h6 class="float-left">Trip Sheet</h6>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-11">
<% #booking_history.transport_plans.each do |transport_plan| %>
<%= f.fields_for :contract_attached_trip_sheets ,transport_plan do |builder| %>
<h3><%= transport_plan.id %> </h3>
<%= render 'contract_attached_trip_sheet_fields', f: builder, transport_plan: transport_plan %>
<% end %>
<% end %>
</div>
<div class="col-md-1">
<%= link_to_add_association "+", f, :contract_attached_trip_sheets, class: "fa fa-user fa-lg" %>
</div>
</div>
</div> <!-- /.inner card body -->
</div> <!-- /.inner card -->
</div> <!-- /. col 12 -->
</div> <!-- /.inner card row -->
</div>
</div>
<div class="card-footer ">
<div class="btn-group float-right">
<%= f.submit "submit", class:"btn btn-primary btn-sm button", id:"generateInvoice" %>
</div>
</div>
</div><!-- /.card -->
<% end %>
</div> <!-- /.container fluid -->
app/views/contract_booking_attached_trips/_contract_attached_trip_sheet_fields.html.erb
<fieldset>
<div class="nested-fields">
<div class="row">
<%= transport_plan %>
<div class="col-md-2">
<label class="label" for="">Initial Odo Reading<span class="star"></span></label>
<div class="md-form form-group">
<%= f.text_field :initial_odo_reading, class: "form-control" %>
</div>
</div>
<div class="col-md-2">
<label class="label" for=""> Trip Start Date<span class="star"></span></label>
<div class="md-form form-group">
<%= f.text_field :trip_start_date_time, class: "form-control"%>
</div>
</div>
<div class="col-md-2">
<label class="label" for=""> Final Odo Reading<span class="star"></span></label>
<div class="md-form form-group">
<%= f.text_field :final_odo_reading, class: "form-control" %>
</div>
</div>
<div class="col-md-2">
<label class="label" for=""> Trip Stop Date<span class="star"></span></label>
<div class="md-form form-group">
<%= f.text_field :trip_stop_date_time, class: "mobile form-control" %>
</div>
</div>
<div class="col-md-2">
<label class="label" for=""> Toll Cost<span class="star"></span></label>
<div class="md-form form-group">
<%= f.text_field :toll_cost, class: "form-control", placeholder:"" %>
</div>
</div>
<div class="col-md-2">
<label class="label" for=""> Permit Cost<span class="star"></span></label>
<div class="md-form form-group">
<%= f.text_field :permit_cost, class: "form-control", placeholder:"" %>
</div>
</div>
<div class="col-md-2">
<label class="label" for="">Parking Cost<span class="star"></span></label>
<div class="md-form form-group">
<%= f.text_field :parking_cost, class: "form-control", placeholder:"" %>
</div>
</div>
<%= f.hidden_field :transport_plan_id, value: transport_plan %>
<div class="col-md-1">
<br/>
<%= link_to_remove_association " " ,f, class:"fa fa-trash ", style: "color:red; font-size:20px; top:14px; " %>
</div>
</div>
<br />
</div>
</fieldset>
i am tryinh to pass transport_plan_id in hidden field but am gettting the following error in
please tell me how to pass the id through nested render partial
In your _form you write
<%= render 'contract_attached_trip_sheet_fields', :f => builder,{ :transport_plan =>transport_plan} %>
and that should be
<%= render 'contract_attached_trip_sheet_fields', :f => builder, :transport_plan =>transport_plan %>
There are two ways to pass data to partials, either you write:
render partial: 'partial_name', locals: {f: builder, a: 123}
or the simple form is just
render 'partial_name', f: builder, transport_plan: transport_plan
i keep getting this missing template error
" Missing template listings/create, application/create with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "/home/codio/workspace/app/views" * "/var/lib/gems/2.2.0/gems/kaminari-0.16.3/app/views" * "/var/lib/gems/2.2.0/gems/commontator-4.10.3/app/views" * "/home/codio/.bundler/ruby/2.2.0/devise-a9d90503e903/app/views" * "/home/codio/.bundler/ruby/2.2.0/koudoku-9e73e64e5520/app/views" * "/var/lib/gems/2.2.0/gems/mailboxer-0.12.4/app/views"
,anytime i tried to create an object,after a couple of search in stack overflow , some suggest to redirect or render , initially in my create action , there was no explicit redirect and after object creation the redirect was done to the show page (the intended behavior).Tried both solutions , but still getting the same error and in my understanding there's no need to have a corresponding views for the create action.
How do i got the create action redirect to the show page without creating a
a view?.
listings_controller.rb
class ListingsController < ApplicationController
...
def create
#listing = Listing.new(listing_params)
if #listing.save
if params[:images]
params[:images].each { |image|
#listing.pictures.create(image: image)
}
end
(#users - [current_user]).each do |user|
Notification.create(recipient: user, actor: current_user, action: "posted", notifiable: #listing)
end
flash[:notice]= "L'annonce #{#listing.listing_number} a eté publiee avec succès."
respond_with(#listing)
end
end
...
end
The form that trigger the create action is rendered via a modal
_form.html.erb
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Publication d'annonce</h4>
</div>
<div class="modal-body">
<%= form_for :listing, :url => {:action => :create} do |f| %>
<div class="form-group row">
<%= f.label :name,"Titre de l'annonce", class: 'col-4 col-form-label'%>
<div class="col-8">
<%= f.text_field :name, placeholder: "Titre de l'annonce",class: "form-control here" %>
</div>
</div>
<div class="form-group row">
<%= f.label :price,"Prix d'offre", class:'col-4 col-form-label'%>
<div class="col-8">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-usd"></i>
</div>
<%= f.text_field :price,placeholder: "Prix d'offre" ,class:"form-control here"%>
</div>
</div>
</div>
<div class="form-group row">
<%= f.label :display_usd ,'Prix en USD', class: 'col-4' %>
<div class="col-8">
<div class="form-check form-check-inline">
<label class="form-check-label">
<%= f.check_box :display_usd, class:'form-check-input' %>
USD
</label>
</div>
</div>
</div>
<div class="form-group row">
<%= f.label :category_id,class:"col-4 col-form-label" %>
<div class="col-8">
<%= f.collection_select :category_id, Category.all, :id, :name, {prompt: "choose a category"}, {class: "form-control here"}%>
</div>
</div>
<div class="form-group row">
<label for="select1" class="col-4 col-form-label">Localisation</label>
<div class="col-8">
<select id="select1" name="select1" class="form-control">
<option value="rabbit">Rabbit</option>
<option value="duck">Duck</option>
<option value="fish">Fish</option>
</select>
</div>
</div>
<div class="form-group row">
<%= f.label :image, "Image Principale", class:'col-4 col-form-label' %>
<div class="col-8">
<%= f.file_field :image, class:'form-control here'%>
</div>
</div>
<div class="form-group row">
<label class="col-4">Condition</label>
<div class="col-8">
<div class="form-check form-check-inline">
<label class="form-check-label">
<input name="radio1" type="radio" class="form-check-input" value="rabbit">
Usé
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input name="radio1" type="radio" class="form-check-input" value="duck">
Neuf
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input name="radio1" type="radio" class="form-check-input" value="fish">
normal
</label>
</div>
</div>
</div>
<div class="form-group row">
<%= f.label :description,'Produit Description', class:'col-4 col-form-label' %>
<div class="col-8">
<%= f.text_area :description,class:" form-control here " do%>
<span id="textareaHelpBlock" class="form-text text-muted">veuillez donner une description exacte de votre produit.</span>
<%end%>
</div>
</div>
<div class="form-group row">
<%= f.label :image, "Image additionel", class:'col-4 col-form-label' %>
<div class="col-8">
<%= file_field_tag "images[]", type: :file, multiple: true, class:'form-control here'%>
</div>
</div>
<div class="form-group row">
<label class="col-4">Sauvegarder sans publier</label>
<div class="col-8">
<div class="form-check form-check-inline">
<label class="form-check-label">
<input name="radio" type="radio" class="form-check-input" value="rabbit">
Unpublished
</label>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
<%= f.button "Publier Produit" , class: 'btn btn-primary pull-right', data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> Publication en cours..."} %>
</div>
<%end%>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
This error comes if you're hitting the create action using HTML. create doesn't typically have an associated view; you use it to process an entity, and redirect the user elsewhere.
Therefore, you should just be able to use:
redirect_to #listing
at the end of your controller code.
Using #listing is a bit of Rails magic - it would more commonly appear as redirect_to listing_path(#listing).
I.E.
def create
#listing = Listing.new(listing_params)
if #listing.save
if params[:images]
params[:images].each { |image|
#listing.pictures.create(image: image)
}
end
(#users - [current_user]).each do |user|
Notification.create(recipient: user, actor: current_user, action: "posted", notifiable: #listing)
end
flash[:notice]= "L'annonce #{#listing.listing_number} a eté publiee avec succès."
redirect_to #listing
end
end
Does that do it?
Another common practice is to have different approaches depending on whether or not an object successfully saves to the db. For example:
def create
#listing = Listing.new(listing_params)
if #listing.save
...
redirect_to #listing, notice: "..."
else
flash.now[:alert] = "Listing failed to save"
render :new
end
end
A good way to play about with this is to use the generator to see how Rails handles things by default - you can use the following in the terminal to have a dig around: rails g controller test_controller.
Hope that helps - let me know if you've any questions.
I have a rails form which is separated in 3 steps, the first step is for the date selected, second step the time select and last step user info's.
Here is the form code :
<%= form_for [#school, Meeting.new], html: { id: 'meeting_form' } do |f| %>
<!-- one step -->
<div class="step">
<section class="container">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<div class="input-group date" id="datetimepicker1">
<%= f.text_field :date, class: 'form-control date_value', :required => true %>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</section>
<button type="button" class="btn btn-primary next-step" style="width: 100%;"> Suite </button>
</div>
<!-- end one step -->
<!-- second step -->
<div class="step">
<section class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker2'>
<%= f.hidden_field :mhour, required: true, class: "Vroomvroom-timepicker--value-js", :value => "" %>
<div class="scheduler--picker">
<% for time in 8..20 %>
<% if time < 10 %>
<div class="scheduler--picker-line-item <% if #school.meeting_already_booked?("0#{time}:00") %>scheduler--picker-line-item--disabled <% end %>" data-value="0<%= time %>:00">
<p>0<%= time %>:00</p>
</div>
<% else %>
<div class="scheduler--picker-line-item <% if #school.meeting_already_booked?("#{time}:00") %>scheduler--picker-line-item--disabled <% end %>" data-value="<%= time %>:00">
<p><%= time %>:00</p>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
</div>
</div>
</section>
<button type="button" class="btn btn-primary previous-step" style="width: 49%;"> Retour </button>
<button type="button" class="btn btn-primary next-step" style="width: 49%;"> Suite </button>
</div>
<!-- end second step -->
<!-- third step -->
<div class="step">
<section class="container">
<div class="row">
<div class='col-sm-6' style="padding-left: 0;">
<div class="form-group">
<label for="name"> Nom </label>
<%= f.text_field :name, html: 'form-control', :required => true, placeholder: 'Votre nom de famille' %>
</div>
<div class="form-group">
<label for="firstname"> Prénom </label>
<%= f.text_field :firstname, html: 'form-control', :required => true, placeholder: 'Votre prénom' %>
</div>
<div class="form-group">
<label for="email"> Adresse email </label>
<%= f.email_field :email, html: 'form-control', :required => true, placeholder: 'Votre adresse mail, ex: jean.marc#gmail.com' %>
</div>
<div class="form-group">
<label for="phone"> Numéro de téléphone</label>
<%= f.text_field :phone, html: 'form-control', :required => true, placeholder: 'Votre numéro de téléphone, ex: 0606060606', :maxlength => 14 %>
</div>
<div class="form-group">
<label> Pour quel type de permis : </label>
<%= f.select :category do %>
<option value="code">Code uniquement</option>
<option value="moto">Permis A (moto)</option>
<option value="voiture">Permis B (voiture)</option>
<option value="am">Permis AM </option>
<option value="formation">Formations 125 cm3 </option>
<option value="autre">Une autre formation</option>
<% end %>
</div>
</div>
</div>
</section>
<button type="button" class="btn btn-primary previous-step" style="width: 49%;"> Retour </button>
<%= button_tag 'Envoyer', :type => :submit, :class => 'btn btn-primary end' %>
</div>
<!-- end thirs step -->
<% end %>
for the date picker, I use bootstrap-datetimepicker for rails, but I create my own time picker, generated with div and data-attributes. I need to get the value of date before submitting the form to know which hours are already taken in DB to disable them.
I have created a method in the model School:
# meetings
def meeting_already_booked?(date, hour)
if Meeting.where(:date => date).where(:time => hour)
return true
else
return false
end
end
And I use the method here :
<div class="scheduler--picker-line-item <% if #school.meeting_already_booked?("0#{time}:00") %>Vroomvroom-scheduler--picker-line-item--disabled <% end %>" data-value="0<%= time %>:00">
I have the time, but I need the date that user selects the step just before to search in my DB if this hour is already taken.
Your best bet is to save the date locally on click of next button, something like
$("#next_step_button").on("click", function(event) {
localStorage.setItem("date", $(#datetimepicker1).val());
});
To get the value back,
localStorage.getItem("date");
I have a ruby form with a text box for start_date and one for end date. I need to add a dropdown for status. I added the select_tag and it populates correctly. My problem is how do I get the value that was selected?
Snippet from form:
<div class="modal-body">
<div class="control-group">
<label class="control-label">From</label>
<div class="controls">
<%= text_field_tag "purchase_requests_from_time", Date.today.beginning_of_month, :class => "text date_picker report_start_time_picker" %>
</div>
</div>
<div class="control-group">
<label class="control-label">To</label>
<div class="controls">
<%= text_field_tag "purchase_requests_to_time", Date.today.end_of_month, :class => "text date_picker report_start_time_picker" %>
</div>
</div>
<div class="control-group">
<label class="control-label">Status</label>
<div class="controls">
<%= select_tag :status, options_for_select(get_purchase_request_statuses) %>
</div>
</div>
<div class="control-group">
<label class="control-label">Status2</label>
<div class="controls">
<%= select_tag "status2", options_for_select(get_purchase_request_statuses) %>
</div>
</div>
</div>
Then when I try to access the params in the controller
from_time = params[:purchase_requests_from_time]
to_time = params[:purchase_requests_to_time]
status = params[:status]
status2 = params[:status2]
The time parameters show up fine, the status and status2 parameters are missing.
params = {ActiveSupport::HashWithIndifferentAccess} ActiveSupport::HashWithIndifferentAccess (4 elements)
'purchase_requests_from_time' = "Tue Mar 01, 2016"
'purchase_requests_to_time' = "Thu Mar 31, 2016"
'action' = "export"
'controller' = "purchase_requests"
Any idea what I am doing wrong?
I found my problem. I was missing the form_tag and was using a link_to rather than a submit_tag. This is the code that works
<div class="modal hide" id="download_purchase_requests">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Download Purchase Requests</h3>
</div>
<%= form_tag({:action => :export, :controller => :purchase_requests}, :multipart => true) do %>
<div class="modal-body">
<div class="control-group">
<label class="control-label">From</label>
<div class="controls">
<%= text_field_tag "purchase_requests_from_time", Date.today.beginning_of_month, :class => "text date_picker report_start_time_picker" %>
</div>
</div>
<div class="control-group">
<label class="control-label">To</label>
<div class="controls">
<%= text_field_tag "purchase_requests_to_time", Date.today.end_of_month, :class => "text date_picker report_start_time_picker" %>
</div>
</div>
<div class="control-group">
<label class="control-label">Status</label>
<div class="controls">
<%= select_tag :purchase_request_status, options_for_select(get_purchase_request_statuses, :selected => params[:purchase_request_status]) %>
</div>
</div>
</div>
<div class="modal-footer">
Close
<%= submit_tag "Download", :class => "btn", :id => "download-btn", :onsubmit => "$('#download-btn').attr('disabled', 'disabled');" %>
</div>
<% end %>
</div>
Suppose there is a form page for Project, which has name and description. Take a look at the render :partial.
<div class="page-header">
<h2>{{project.id ? 'Edit ' : 'Add new'}} project</h2>
</div>
<div class="row">
<div class="col-xs-6 col-xs-offset-2">
<form class="form-horizontal">
<%= render :partial => 'templates/forms/text', :object => 'name', :locals => {:model => 'project'} %>
<%= render :partial => 'templates/forms/text', :object => 'description', :locals => {:model => 'project'} %>
<div class="form-group">
<div class="col-xs-offset-3 col-xs-9">
<button ng-click="saveProject()" type="submit" class="btn btn-success">Submit</button>
<a ng-href="{{ path('UserIndexCtrl') }}" class="btn btn-default">Back</a>
</div>
</div>
</form>
</div>
</div>
And here is a partial being used.
<div class="form-group" ng-class="{'has-error': errors.<%= text.underscore %>}">
<label for="<%= model %>.<%= text %>" class="col-xs-3 control-label"><%= text.titleize.humanize %></label>
<div class="col-xs-9">
<input id="<%= model %>.<%= text %>" name="<%= model %>.<%= text %>" type="<%= local_assigns[:type] || 'text' %>" class="form-control" ng-class="{'text-danger': true}" ng-model="<%= model %>.<%= text %>">
<span class="help-block" ng-show="errors.<%= text.underscore %>"><%= text.titleize.humanize %> {{errors.<%= text.underscore %>.join(', ')}}</span>
</div>
</div>
I am not sure this is the proper way to do a partial rendering in Rails + AngularJs combo. Wonder if there's a more angular-ish way? Thanks!
I would use a Helper to generate the input instead of writing directly in the HTML, something like:
def input_for_model(model_name, text, options = { }) # I actually have no idea what is doing your input, you can probably find a better name
options = { id: "#{model_name}.#{text}", name: "#{model_name}.#{text}",
type: 'text', class: 'form-control',
ng-class: "{'text-danger': true}",
ng-model: "#{model_name}.#{text}"
}.merge(options)
tag(:input, options)
end
And use it like this:
<div class="form-group" ng-class="{'has-error': errors.<%= text.underscore %>}">
<label for="<%= model %>.<%= text %>" class="col-xs-3 control-label"><%= text.titleize.humanize %></label>
<div class="col-xs-9">
<%= input_for_model(model, text, type: local_assigns[:type] || 'text') %>
<span class="help-block" ng-show="errors.<%= text.underscore %>"><%= text.titleize.humanize %> {{errors.<%= text.underscore %>.join(', ')}}</span>
</div>
</div>