Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在rails中搜索select_标记?_Ruby On Rails_Search_Full Text Search_Html Select - Fatal编程技术网

Ruby on rails 在rails中搜索select_标记?

Ruby on rails 在rails中搜索select_标记?,ruby-on-rails,search,full-text-search,html-select,Ruby On Rails,Search,Full Text Search,Html Select,我有三种型号Lcities和lservices和search class Lcity < ActiveRecord::Base has_many :Lservices attr_accessible :lname , :lcode , :lexperience , :lrating , :llocation end 用于搜索的表单 <%= form_for (@search) do |f| %> <%= f.select(:city, city_for_sel

我有三种型号
Lcities
lservices
search

class Lcity < ActiveRecord::Base
 has_many :Lservices
attr_accessible  :lname , :lcode , :lexperience , :lrating , :llocation
end
用于搜索的表单

 <%= form_for (@search) do |f| %>
  <%= f.select(:city, city_for_select, :prompt => 'Select City') %>
 <%=f. select(:service, service_for_select, :prompt => 'Select Services') %>
 <% end %>

“选择城市”)%%>
“选择服务”)%%>

首先,您的符号必须向下显示:

has_many :lservices

其次,您的SQL是从右到左的。。。而且,这几乎毫无意义。但是,为了满足custommer的要求,它应该是(注意表的复数形式):

对于您的查询:

Lcity.joins(:lservices).where("lservices.lname = lcites.llocation")
不确定你期望得到什么样的结果,但答案与你的问题相符

has_many :lservices
belongs_to :lcity
select lname from lcites,lservices where lcites.llocation = lservices.lname
Lcity.joins(:lservices).where("lservices.lname = lcites.llocation")