I manage the orders made by the customers. My Order table is connected to the model Cart. The model Cart is connected to the Product model Many to Many which gave the association table line_items which includes id_cart, id_product, and quantity. But for the Cart, I want to add the option to update and delete an element of the Cart. I met a blocking - more precisely in the view Order where at the end I show the list of the elements in the Cart as follows
<h3> Order Details </ h3>
<table class = "table-bordered table">
<td> Designation </ td> <td> Quantity </ td> <td> Price </ td> </ tr>
<% order.cart.line_items.each do | item | %>
<tr align = "center">
<td> <% = f.text_field: product_id,: value => item.product.title,: readonly => true, class: 'form-control'%> </ td>
<td> <% = f.text_field: qte,: value => item.qte, class: 'form-control'%> </ td>
<td> <% = number_to_currency (product.inc.unit, unit: "F", separator: ",", format: "% n% u")%> </ td>
</ Tr>
<% end%>
</ Table>
There I will have the fields textfield with default value what the customer had ordered allowing the modification. But the problem is that the attibutes product_id and qte do not belong to the model order but earlier to the model line_items, so I will not have permission to insert:
unpermitted parameters: :product_id, :qte
I even try the method accepts_nested_attributes_for and I will have permission. But the transaction will not commit but rollback.
And thank you for helping me for this bug that prevents me from advancing for days
the submitted params look like this
<%= form_with(model: order,:remote => true) do |f| %>
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="header">
<h4 class="title"> Edite Order</h4>
</div>
<div class="content">
<div class="row">
<!-- Order Reference-->
<div class="col-md-5">
<div class="form-group">
<label><%= f.label :ref,"Reference Order "%></label>
<%= f.text_field :ref, :value => "ABC-123-NY#{#order.id}",:readonly => true,class: ' form-control' %>
</div>
</div>
<!-- Supplier List -->
<div class="col-md-5">
<div class="form-group">
<label><%= f.label :supplier_id,"Fournisseur"%></label>
<%=f.collection_select :supplier_id,Fournisseur.all,
:id,:namefrs,{required: true},id:"listfrs",class: 'form-control'%>
</div>
</div>
<!-- boutton update -->
<div class="col-md-2">
<div class="form-group">
<%= f.submit 'Modifier',:name => "valid",:class => 'btn btn-info btn-fill pull right'%>
</div>
</div>
</div>
</div>
</div>
<div class="card">
<div class="content">
<div class="row">
<!-- Date Order -->
<div class="col-md-5">
<div class="form-group">
<label><%= f.label :date_order,"Date"%></label>
<%= f.date_select :date_order, label: false, placeholder: "Sélectionnez la date et l'heure",class: 'form-control'%>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col" id="cart">
<h3>Order</h3>
<table class="table table-bordered">
<tr align="center" class="h4">
<td>Designation</td>
<td>Quantity</td>
<td>Price</td>
</tr>
<% order.cart.line_items.each do |item| %>
<tr align="center">
<td><%= f.text_field :product_id,:value => item.product.title,:readonly => true,class: 'form-control'%></td>
<td><%= f.text_field :qty, :value=>item.qty ,class: 'form-control' %></td>
<td><%= number_to_currency(item.product.price, unit: "F",separator:",",format:"%n %u")%></td>
</tr>
<% end %>
</table>
</div>
<% end %>
i have this in my controller Order
def update
respond_to do |format|
#order.cart.line_items.each do |item|
item.qty = params[:qty]
end
format.html { redirect_to #order, notice: 'Order was successfully updated.' }
end
end
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'm trying to do an edit object in Ruby on Rails using a modal form, when I try to do the link_to edit_plane_path(plane) in planes.html.erb I get the following error:
undefined local variable or method `plane' for #<#:0xd580e98>
Did you mean? #plane
plane_url
#planes
However, trying any of those doesn't really change the fact that I still get an error on the page and I can't even load it.
planes.html.erb
<table>
<thead>
<tr>
<th>Image</th>
<th>Operating agency</th>
<th>Date</th>
<th>Call sign</th>
<th>Country</th>
<th>Info</th>
<th>Action</th>
</tr>
<thead>
<tbody>
<% #planes.each do |p| %>
<tr class="gradeC">
<td>
<%= image_tag(p.image, size: "150x150")%></td>
<td class="w-25"><%= p.provider%>
</td>
<td><%= p.brand%></td>
<td class="center"><%= p.year%></td>
<td class="center"><%= p.call_sign%></td>
<td><%= p.country%></td>
<td><%= p.info%></td>
<td class="text-right">
<div class="btn-group">
<%= link_to 'Edit', edit_plane_path(plane), remote: true, :class =>'btn white btn btn-xs' %>
<button class="btn-white btn btn-xs">Delete</button>
</div>
</td>
</tr>
</tbody>
<% end %>
</table>
_form.html.erb
<!-- FORM EDIT -->
<div id="edit-plane" class="modal fade" aria-hidden="true">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-body">
<div class="row">
<div class="col-sm-12"><h3 class="m-t-none m-b">Edit plane</h3>
</div>
</div>
<%= form_for #plane, url: planes_path, remote: true do |f| %>
<div class="form-group row">
<div class="col-sm-6">
<label>Brand</label>
<%= f.text_field :brand, class:"form-control"%>
</div>
<div class="col-sm-5">
<label>Model</label>
<%= f.text_field :model, class:"form-control"%>
</div>
</div>
<div class="form-group row">
<div class="col-sm-5">
<label>Year</label>
<%= select_tag :hyear, options_for_select(["2015","2016","2017","2018","2019"], "2019"), class:"select2_demo_1 form-control" %>
<%= f.hidden_field :year %>
</div>
<div class="col-sm-6">
<label>Country</label>
<%= select_tag :hcountry, nil, class:"select2_demo_1 form-control" %>
<%= f.hidden_field :country %>
</div>
<script language="javascript">
populateCountries("hcountry");
</script>
</div>
<div class="form-group row">
<div class="col-sm-6">
<label>Provider</label>
<%= select_tag :hprovider, options_for_select([ "Test", "Test2"], "Test"), class:"select2_demo_1 form-control"%></select>
<%= f.hidden_field :provider %>
</div>
<div class="col-sm-5">
<label>Tactical call sign</label>
<%= f.text_field :call_sign, class:"form-control"%>
</div>
</div>
<div class="form-group row">
<div class="col-sm-6">
<label>Extra info</label>
<%= f.text_area :info %>
</div>
<div class="col-sm-5">
<label>Image</label>
<%= f.file_field :image %>
</div>
</div>
<!-- SUBMIT -->
<button class="btn btn-primary btn-lg float-right ml-2" id="cancelbtn">Cancel</button>
<%= f.submit "Submit", id:"edpla", class: 'btn btn-primary btn-lg float-right'%>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>
edit.js.erb
// Add the dialog title
$('#edit-plane h3').html("<i class=' glyphicon glyphicon-pencil'></i> Edit Plane");
// Render the edit form
$('.modal-body').html('<%= j render("form") %>');
// Show the dynamic dialog
$('#edit-plane').modal("show");
// Set focus to the first element
$('#edit-plane').on('shown.bs.modal', function () {
$('.first_input').focus()
})
update.js.erb
$('#edit-plane').modal('toggle');
$('#customer_<%= #plane.id %>').replaceWith('<%= j render (#plane) %>')
planes_controller.rb
class PlanesController < ApplicationController
def planes
#plane = Plane.new
#planes = Plane.all
end
def create
#plane = Plane.new(plane_params)
if #plane.save
flash[:success] = "Plane successfully added"
redirect_to :planes => 'post', :action => 'planes'
else
flash[:error] = "Something went wrong"
render 'planes'
end
end
def edit
#plane = Plane.find(params[:id])
end
def update
respond_to do |format|
if #plane.update(plane_params)
format.json { head :no_content }
format.js
else
format.json { render json: #customer.errors.full_messages, status: :unprocessable_entity }
end
end
end
private
def plane_params
params.require(:plane).permit(:brand, :model, :provider, :call_sign, :user, :country, :image, :info, :year)
end
end
My goal is to edit a plane in the table through a modal form, but I can't even show the page at the moment.
Here:
<% #planes.each do |p| %>
...you are passing each plane as p. Therefore, try:
<%= link_to 'Edit', edit_plane_path(p), remote: true, class: 'btn white btn btn-xs' %>
i have a 3 models user ,user_role and store .user_role belongs to user and store.i have a member controller where i have a search box one for stores,one for user_role(both are select box)below is method for search in user_role model
def self.filter(params)
filter = params[:search] || {}
user_roles = order(role_type: :asc)
if filter[:name].present?
end
if filter[:email].present?
end
if filter[:role].present?
user_roles = user_roles.where(role_type: filter[:role])
end
if filter[:store_id].present?
user_roles = user_roles.where(store_id: filter[:store_id])
end
user_roles
end
This is my member controller below
def index
if current_user.super_admin?
#total_user_roles = UserRole.filter(params).order(sort_column + " "
+ sort_direction)
#user_roles = #total_user_roles.page(params[:page]).per(10)
else
stores = current_user.user_roles.where(:role_type.in =>
['store_manager', 'merchant']).pluck(:store_id)
#total_user_roles = UserRole.where(:store_id.in =>
stores).filter(params).order(sort_column + " " + sort_direction)
#user_roles = #total_user_roles.page(params[:page]).per(10)
end
respond_to do |format|
format.html
format.csv { send_data #users.to_csv }
end
end
def sort_column
User.attribute_names.include?(params[:sort]) ? params[:sort] :
"first_name"
end
def sort_direction
%w[asc desc].include?(params[:direction]) ? params[:direction] :
"asc"
end
My search form in view.Should i change anything here in name and email field or just leave it as itis?
<section>
<div class="col-md-12">
<div class="row">
<section class="content-header">
<div class="white card-2">
<h3>Users</h3>
</div>
</section>
</div>
<div class="form white">
<!-- form start -->
<form class="form-horizontal">
<div class="box-body">
<h3>Search Users </h3>
<div class="col-md-3">
<label class="control-label"
for="order_search_order_number">First Name</label>
<input class="form-control" id="order_search_order_number"
name="search[name]" type="text" value="">
<span class="md-input-bar"></span>
</div>
<div class="col-md-3">
<label class="control-label">Email</label>
<input class="form-control" id="order_search_order_number"
name="search[email]" type="text">
<span class="md-input-bar"></span>
</div>
<div class="col-md-3 input">
<label class="control-label">Roles</label>
<%= select_tag("search[role]",
options_for_select(User::ADMIN_ROLES.map { |e| [e.humanize, e]},
params[:search] && params[:search][:role]), include_blank: true,
class: 'select2') %>
<span class="md-input-bar"></span>
</div>
<div class="col-md-3">
<label class="control-label">Store</label>
<%= select_tag("search[store_id]",
options_for_select(Store.all.order('name ASC').map { |e|
[e.name, e.id] }, params[:search] && params[:search][:store_id]),
include_blank: true, class: 'select2') %>
<span class="md-input-bar"></span>
</div>
</div>
<h4 class="pull-right"> Total Users: <b> <%=
#total_user_roles.count %></b>
</h4>
<br><br>
<div class="box-footer">
<button type="submit" class="btn btn-info">Filter</button>
Clear
</div>
<!-- /.box-footer -->
</form>
</div>
</div>
</section>
<div class="col-md-12">
<section class="section-data">
<!-- Section Data Table -->
<div class="row">
<div class="col-md-12">
<div class="box">
<div class="box-body table-responsive custom-sort">
<table class="table table-striped table-bordered nowrap data-
table" cellspacing="0" width="100%">
<thead>
<tr>
<th><%= sortable 'first_name', "Name" %></th>
<th><%= sortable 'email' %></th>
<th>Store</th>
<th><%= sortable 'role' %></th>
<th>Status</th>
<th>Action</th>
<th>Active?</th>
</tr>
</thead>
<tbody>
<% #user_roles.each do |role| %>
<tr>
<td><%= role.user.name%></td>
<td><%= role.user.email %></td>
<td><%= role.store.try(:name) %></td>
<td><%= role.role_type.try(:humanize) %></td>
<td><%= role.user.pending_invitation? ? "Pending" :
"Accepted" %></td>
<td>
<a class="ion-edit actions" href="/admin/members/<%=
role.id %>/edit"></a>
<% if role.user != current_user %>
<a class="ion-android-delete actions red" data-
sweet-alert-confirm="<%= t(:delete_confirm) %>" data-
method="delete" href="/admin/members/<%= role.user.id %>"></a>
<% end %>
</td>
<td>
<div class="onoffswitch">
<input type="checkbox" name="active" <%= "checked" if
role.user.active %> class="onoffswitch-checkbox" id="<%=
role.user.id %>" data-id="<%= role.user.id %>">
<label class="onoffswitch-label" for="
<%=role.user.id %>">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</tr>
<% end %>
</tbody>
</table>
<div class="pull-right">
<%= paginate #user_roles, :theme => 'twitter-bootstrap-3' %>
</div>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
</div>
</section>
</div>
now i want to implement search for user name and email ,i tried lots of ways but cant come up with solution.as Iam not expert need some solution from a expert .iam using mongoid search gem.
I'm new to Rails and I'm trying to build a nice application and I'm struggling with arrays, I have 4 arrays that I want to iterate and they are not the same size
I want to generate sections in HTML using the first array what I did it
#sections = ['Section One','Section Two','Section Three','Section Four']
#itemsOne = ['item 1','item 2','item 3','item 4','item 5','item 6']
#itemsTwo = ['item 1','item 2','item 3','item 4','item 5','item 6']
I was using
<%= #sections.zip(#itemsOne, #itemsTwo).each do |t1, t2, t3| %>
<%= t1 %>
<table>
<tbody>
<tr>
<td>
<%= t2 %> | <%= t3 %>
</td>
<td>
<%= t2 %> | <%= t3 %>
</td>
<td>
<%= t2 %> | <%= t3 %>
</td>
</tr>
</tbody>
</table>
<% end %>
I have a table that have a Section Title and cells that have two values
but what I get is the value of |t2| in each cell of |t1| section
using #Phil answer down below, but he deleted it.
<%= #sections.zip(#itemsOne, #itemsTwo).each do |t| %>
<%= t[0] %>
<table>
<tbody>
<tr>
<td>
<%= t[1] %> | <%= t[2] %>
</td>
<td>
<%= t[1] %> | <%= t[2] %>
</td>
<td>
<%= t[1] %> | <%= t[2] %>
</td>
</tr>
</tbody>
</table>
<% end %>
p.s. the itemsOne and itemsTwo arrays have more than 20 values.
What I created is separated my big arrays into smaller ones and then Iterated thru each this way without a Table because table was making design issues so i went into div's using bootstrap 3 column, there might be a better way but this is what i got as a beginner.
<div class="row">
<div class="col-md-12">
<h4><%= #Sections[0] %></h4>
<!-- This will Display Section 0 in the Array -->
</div>
<div class="row">
<div class="col-md-12">
<% #count = 0 %>
<!-- Counter is Zero -->
<% #ItemsOne.collect do |t1| %>
<!-- This will loop array to increment the #count and repeat the HTML -->
<% #count += 1 %>
<!-- With each loop increment by 1-->
<div class="col-md-3">
<div class="col-md-12">
<label>
<input type="checkbox" name="optionsCheckboxes">
<%= #ItemsOne[#count - 1] %>
<!-- Counter should start from 0 adding -1 will make it start
from 0 instead of 1 and then will print the value of the Index Number -->
</label>
</div>
</div>
<% end %>
</div>
</div>
</div>
Here is another way to do this
<div class="row">
<% #Sections.each_with_index do |x1, n| %>
<div class="row">
<div class="col-md-12">
<h4><%= #Sections[n] %></h4>
</div>
<div class="row">
<div class="col-md-12">
<% if n == 0 %>
<% #itemsOne.each_with_index do |t1, n| %>
<div class="col-md-3">
<div class="col-md-12">
<label>
<input type="checkbox" name="optionsCheckboxes">
<%= #itemsOne[n] %>
</label>
</div>
</div>
<% end %>
<% elsif n == 1 %>
<% #itemsTwo.each_with_index do |t1, n| %>
<div class="col-md-3">
<div class="col-md-12">
<label>
<input type="checkbox" name="optionsCheckboxes">
<%= #itemsTwo[n] %>
</label>
</div>
</div>
<% end %>
<% elsif n == 2 %>
<% #itemsThree.each_with_index do |t1, n| %>
<div class="col-md-3">
<div class="col-md-12">
<label>
<input type="checkbox" name="optionsCheckboxes">
<%= #itemsThree[n] %>
</label>
</div>
</div>
<% end %>
<% elsif n == 3 %>
<% #itemsFour.each_with_index do |t1, n| %>
<div class="col-md-3">
<div class="col-md-12">
<label>
<input type="checkbox" name="optionsCheckboxes">
<%= #itemsFour[n] %>
</label>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
I'm having a problem with my advanced search.
Essentially, its an advanced search for bands (name, style, bandpicture by checkboxes (checked: have a bandpicture))
Here is the code.
result.html.erb
<table >
<colgroup>
<col width="250" />
</colgroup>
<tr>
<td>
<label for="name">Filter</label></br>
<%= form_tag band_path do %>
<label for="Style">Style</label></br>
<%= select_tag :style_id, options_from_collection_for_select(Style.all, :id, :name, params[:style_id]), include_blank: true, class: "form-control" %>
<br>
</br>
<%= check_box_tag 'options[]', "picture" %>
<%= button_to '#', class: 'btn btn-default' do %>
<%= t(:find) %>
<% end %>
<% end %>
</td>
<td>
<div>
<% #bands.each do |band|%>
<div class="top-bar">
<div class="center">
<div class="info">
<div class="name"><%=band.id %></div>
<div> <%= band.zip %>, <%= band.city %> </div>
</div>
<div class="desc">
<table>
<tr>
<td>Styles</td>
<td>
<% band.styles.each do |s| %>
<%= s.style.name %>
<% end %>
</td>
</tr>
</table>
</div>
<% end %>
</td>
</tr>
</table>
models band.rb
def self.search1(style_id)
Profile.joins("...").where("style_id = ?", style_id)
end
controller.
def searchresult
if params[:style_id].present?
#bands = Band.search1 params[:style_id]
elsif params[:options]
Band.where(:options => #filtered_options)
else
#bands = Band.all
end
end
The searchresult don't show the result of the checkboxes and I have this errors:
undefined method `search1' for #<Class:0x00000008eb5548>