Search On Select_tag In Rails?
I have three models Lcities and lservices and search class Lcity < ActiveRecord::Base has_many :Lservices attr_accessible :lname , :lcode , :lexperience , :lrating , :llocatio
Solution 1:
To start with, your symbols have to be downcased:
has_many :lservices
and
belongs_to :lcity
Second, your SQL is slightly right-to-left... Also, it makes little to no sense. However, to satisfy the custommer, it should be (mind the plural for tables):
select lname from lcites,lservices where lcites.llocation = lservices.lname
For your query:
Lcity.joins(:lservices).where("lservices.lname = lcites.llocation")
Not sure what kind of results you're expecting, but the answer matches your question.
Post a Comment for "Search On Select_tag In Rails?"