🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.ruby
2 messages
2 total messages Started by BuKoX Thu, 18 Sep 2008 19:20
Problem z ActiveRecord i belongs_to
#1147
Author: BuKoX
Date: Thu, 18 Sep 2008 19:20
29 lines
1831 bytes
Witam.
Tworze pierwszy projekt w RoR wiec prosze o wyrozumialosc. Czytalem 
dokumentacje ale nie znajduje rozwiazania swojego problemu. Otoz mam 2 
tabele: user i task. W tabeli task jest klucz obcy responsible_id (do 
pola user.id). Mam takie modele:

class User < ActiveRecord::Base
   has_many :tasks, :foreign_key => "responsible_id"
end

class Task < ActiveRecord::Base
   belongs_to :user, :foreign_key => "responsible_id", :class_name => 
"User"
end

Przy probie dodania nowego rekordu do tabeli user dostaje komunikat: 
'undefined method `passwd=' for #<Task:0x415ed6c> czyli tak jakby 
dodanie rekordu user miało mieć odzwierciedlenie w tabeli task czyli 
albo cos jest skopane z relacja albo sam juz nie wiem co. Co moze byc 
powodem?

PS. Mam pluralize_table_names = false

pozdrawiam...

-- 
  __            __     ______________________________           __ ___
|__\ |  | |_/ /  \ \_/  Blog: http://bukox.pl       |    |\ | |_   |
|__/ |__| | \ \__/ / \____TC: http://totalcmd.pl/ _/  <> | \| |__  |
Re: Problem z ActiveRecord i belongs_to
#1146
Author: BuKoX
Date: Tue, 23 Sep 2008 17:57
32 lines
1953 bytes
BuKoX pisze:

> Witam.
> Tworze pierwszy projekt w RoR wiec prosze o wyrozumialosc. Czytalem 
> dokumentacje ale nie znajduje rozwiazania swojego problemu. Otoz mam 2 
> tabele: user i task. W tabeli task jest klucz obcy responsible_id (do 
> pola user.id). Mam takie modele:
> 
> class User < ActiveRecord::Base
>   has_many :tasks, :foreign_key => "responsible_id"
> end
> 
> class Task < ActiveRecord::Base
>   belongs_to :user, :foreign_key => "responsible_id", :class_name => "User"
> end
> 
> Przy probie dodania nowego rekordu do tabeli user dostaje komunikat: 
> 'undefined method `passwd=' for #<Task:0x415ed6c> czyli tak jakby 
> dodanie rekordu user miało mieć odzwierciedlenie w tabeli task czyli 
> albo cos jest skopane z relacja albo sam juz nie wiem co. Co moze byc 
> powodem?
> 
> PS. Mam pluralize_table_names = false

Juz niewazne. Mialem blad w modelu.

pozdrawiam...

-- 
  __            __     ______________________________           __ ___
|__\ |  | |_/ /  \ \_/  Blog: http://bukox.pl       |    |\ | |_   |
|__/ |__| | \ \__/ / \____TC: http://totalcmd.pl/ _/  <> | \| |__  |
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads