MS SQL (legacy) relations not working

I have my app talking to the MS SQL database. meaning I can retrieve
data from it.
I have an Office table. and it has a column called ‘Marketing’ that is
a foreign key to the marketing tables primary key.

so I was have trouble and I set up a test environment on mac using
I set the tables up the same way as the MQ SQL server.

here are the models

class Office < ActiveRecord::Base
set_table_name “Office”
self.primary_key = “OfficeID”

belongs_to :marketing,
:class_name => “Marketing”,
:foreign_key => “Marketing”

class Marketing < ActiveRecord::Base
set_table_name “marketing”
self.primary_key = “marketingid”

has_many :offices

/*** controller ***/
class OfficeController < ApplicationController

def index
@offices = Office.find(:all)

/*** index.rhtm ***/

<% for office in @offices %>
<%= office.Name %> - <%= %>
<% end %>
<%= debug @offices %>

this code works with the locomotive set up (MySQL database) and the
instant rails set up with MySQL database
but when I use the same code on the instantrails using the MS SQL
server I get this error.

You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.first_name

I am confused.
if I take out the <%= %> part of code it
runs and in the debug it shows “Marketing”=>4 - which is correct but
it also doesn’t show the marketing object within the office object.

anybody have any ideas?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs