我的代码中没有显示错误,我使用 Ransak 搜索,但我没有得到搜索输出。当我从复选框中检查大小选项时,我想获得输出。如果我点击中号,我想显示所有中号连衣裙,请给我一个解决方案
这是我的复选框
这是我的代码
产品/index.html.slim
= search_form_for @product_search, url: shop_index_path do |f|
= f.label :size_cont, "Size Available"
- StandardSize.all.each do |s|
= check_box_tag('product_search[standard_sizes_id_eq_any_cont][]', s.id )
= s.name
这是我的 ShopController.rb
class ShopController < ApplicationController
def index
@product_search = Product.ransack(params[:q])
@products = @product_search.result(distinct:true).page(params[:page]).per(8)
@product_search.build_sort if @product_search.sorts.empty?
end
模型标准尺寸.rb
class StandardSize < ActiveRecord::Base
belongs_to :product
end
这是我的模型 product.rb
class Product < ActiveRecord::Base
has_and_belongs_to_many :standard_sizes
end
这是我的服务器获取
Started GET "/shop?utf8=%E2%9C%93&q%5Bname_cont%5D=dress&q%5Bprice_paisas_gteq%5D=&q%5Bprice_paisas_lteq%5D=&product_search%5Bstandard_sizes_id_eq_all%5D%5B%5D=3&commit=Search" for 10.0.2.2 at 2015-07-23 10:12:42 +0000
Cannot render console from 10.0.2.2! Allowed networks: …
我想用空格分隔货币和总额.
请给我一个解决方案任何帮助将不胜感激.
p
strong Total:
span
= @order.currency
= humanized_money_with_symbol @order.total_paisas/100
Run Code Online (Sandbox Code Playgroud) 根据选择选项,我需要上传 pdf 或 mp3/mp4。
如果我选择书籍或试卷,我只需要验证才能上传 pdf 或 doc 文件,
如果我选择音频,我应该只上传 mp3。如果我选择视频,我应该只上传 mp4。
请帮助我使用 javascript 进行此验证。我只需要条件。其余的将通过后端完成
<select id="upload_material" onchange="val()">
<option>Select Material Type</option>
<option value="1">Question Paper</option>
<option value="2">Book</option>
<option value="3">Audio/Video</option>
</select>
<label class="myLabel">
<%= f.file_field :attachment, :onchange => "get_extension($this.value)" %>
<!-- <input type="file" style="margin-left:80px;" name="filetwo"> -->
<span>Browse</span>
</label>
Run Code Online (Sandbox Code Playgroud) 当我单击每个按钮时,我想status将properties表中的值更新为(1 或 2 或 3 或 4)。
这些是我的视图文件中的按钮:
<td><%= link_to("Waiting for Response", rms_property_approve_property_path(property, {:status => 'Waiting for Response'}), method: :patch, class: "btn btn-success", "data-no-turbolink" => true) %><td>
<td><%= link_to("No Response", rms_property_approve_property_path(property, {:status => 'No Response'}), method: :patch, class: "btn btn-danger", "data-no-turbolink" => true) %><td>
<td><%= link_to("Registered", rms_property_approve_property_path(property, {:status => 'Registered'}), method: :patch, class: "btn btn-success", "data-no-turbolink" => true) %><td>
<td><%= link_to("Not Interested", rms_property_approve_property_path(property, {:status => 'Not Interested'}), method: :patch, class: "btn btn-danger", "data-no-turbolink" => true) %><td> …Run Code Online (Sandbox Code Playgroud) 如何从关联中获取记录。我的工作表中有4个工作。如何使用resource_type_id = 2过滤所有工作。从下面的记录中,例如(我想获得2和3作为结果的工作ID)。
这是我的协会
class Job < ActiveRecord::Base
has_many :jobs_resources
has_many :resource_type, through: :jobs_resources, dependent: :destroy
end
class ResourceType < ActiveRecord::Base
has_many :jobs_resources
has_many :jobs, through: :jobs_resources, dependent: :destroy end
class JobsResource < ActiveRecord::Base
belongs_to :job
belongs_to :resource_type
end
Run Code Online (Sandbox Code Playgroud)
这是我的resources_type表的保存方式
请帮助任何帮助
当我调用国家/地区列表时,我从API获取以下数组作为JSON:
{
"countries": [
[
"Andorra",
"AD"
],
[
"United Arab Emirates",
"AE"
],
[
"Afghanistan",
"AF"
],
[
"Antigua and Barbuda",
"AG"
],
[
"Anguilla",
"AI"
],
[
"Albania",
"AL"
],
[
"Armenia",
"AM"
]]}
Run Code Online (Sandbox Code Playgroud)
这是我的控制器:
def find_countries
@countries = CountryStateSelect.countries_collection
render :json=>{ :countries=> @countries }
end
Run Code Online (Sandbox Code Playgroud)
我想像这样分开这个国家/地区列表数组.
{
"countries": [
[
value:"Andorra",
key: "AD"
],
[
value: "United Arab Emirates",
key:"AE"
],
[
value: "Afghanistan",
key:"AF"
],
[
value:"Antigua and Barbuda",
key:"AG"
]
]}
Run Code Online (Sandbox Code Playgroud)
我无法确定价值和关键.如何将上述JSON响应分开?