Thanks for replying so quickly. In a nutshell, yes. An Agency has many
People. Essentially the purpose of the project is to perform an
interim admin function to sync two systems. Hence there are two sets
of Primary keys and two tables. The third table is the output, where
it records the Agency business number to ensure that the Agency is
registered. Obviously there will be multiple Agency profiles for the
two systems with the primary keys for the agencies. Currently this is
being done manually.
What I want to find out now is how to generate the view to encompass
the values from all three tables into one view, when I am using one of
the two system generated lists as a list for users to determine if a
client has been registered or not. E.g
Agency ID 2 is clicked, which is linked to only one Agency Business
Number. How do I represent the values for this Agency ID 2 from the
other two tables? Obviously some Agency IDs will not have a
corresponding Agency Business Number in table 3 as they have not been
registered as yet, or in Table 2 for that matter. I am envisaging the
use of partials.
I worked out how to generate primary and foreign keys. Currently I
have some code in my model that does this, but is not the best.
FasterCSV.foreach("D:/Rails/MySql/Migration/file.csv) do |row|
agency = Agency.new(:OrganisationName=>row,:TPID=>row) do
i.Agency_ID1 = (row)
contact = person.new(:ContactFname=>row,:ContactLname=>row
:ContactFax=>row,:ContactEmail=>row) do |si|
i.ContactID = (row)
It’s meant to be interim code that helps me load primary key values.
I also have a search function working with Acts_as_ferret.
This is the model code for Agency 2 (list)
acts_as_ferret :fields => [:OrganisationName]
This is the controller
class SearchesController < ApplicationController
query = params[:q]
@Agency2 = Agency_ID2.find_with_ferret query, :page => params
[:page], :per_page => 50
This is the view in views/searches
<% @sbtradesuppliers.each do |s| %>
<% end %>
|<%= link_to s.OrganisationName, Agency2_path(s.id) %>
||<%= s.Agency Business Number%>
||<%= s.Agency ID 2%>
<%= will_paginate @Agency2 %>
My last question is, is this restful?
Any help would be much appreciated.