I am working with a rails app and have begun to work on a search function using metasearch but I am having troubles getting the correct method for the search.
For example I have a model (Proposal) that has a field cost.
..model/proposal.rb
class Proposal < ActiveRecord::Base
belongs_to :user
has_many :users, :through => :invitations
attr_accessible :cost, :user_id
For which this code works fine with meta search
..views/homes/live_requests.html.erb
<%= form_for @search, :url => "/live_requests", :html => {:method => :get} do |
<%= f.label :cost_greater_than %>
<%= f.text_field :cost_greater_than %><br />
<!-- etc... -->
<%= f.submit %>
Yet with a more complicated association I can not manage to get the meta search path correct.
I am trying to search over:
Proposal.last.user.suburb.name #Returns the name of the suburb as expected
I have tried many associations but cannot find the right one.
Proposal has a user_id field which maps to user So Proposal.user returns a User User then has a suburb_id which returns a suburb Suburb has a field called name which returns a string
How would I work this into a metasearch form?
<%= f.text_field :user_user_suburb_name %>
or
<%= f.text_field :user_id_suburb_id_name %>
I cannot come to a solid conclusion.
Thanks for your help in advance.