Frederick Cheung wrote:
> On Jun 4, 12:03�am, Bill McGuire <[email protected]>
> wrote:
>> E. Litwin wrote:
>> > Is there any reason you need the underscores in your model names?
>> > i.e. Try naming it FreakProject instead of Freak_Project if possible.
>>
>> > On Jun 1, 11:10 am, Bill McGuire <[email protected]>
>>
>> Thanks E and Frederick but no luck. Not really sure what's gone wrong.
>
> So what did you try and with what results ?
>
> Fred
Got it to work. Can't believe i missed this. Foreign key was missing in
one model and was not foreign in the other (it was same as primary).
-----------------------------------------------------------
class Freak_Item < ActiveRecord::Base
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:encoding => "utf8",
:username => "root",
:database => "taskfreak",
:socket => "/var/lib/mysql/mysql.sock"
)
self.table_name = 'frk_item'
self.primary_key = 'itemId'
belongs_to :freak_project <<<< WAS MISSING THE FOREIGN_KEY
end
-----------------------------------------------------------
class Freak_Project < ActiveRecord::Base
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:encoding => "utf8",
:username => "root",
:database => "taskfreak",
:socket => "/var/lib/mysql/mysql.sock"
)
self.table_name = 'frk_project'
self.primary_key = 'projectId'
has_many :freak_items, :foreign_key => "projectId" <<<< WRONG
FOREIGN_KEY - NEEDS TO BE itemId
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---