irb(main):038:0> Ressort.find(1).workers
NoMethodError: undefined method `workers' for #<Ressort:0x3215328>
irb(main):039:0> Worker.first.ressort
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column:
ressorts.worker_id: SELECT "ressorts".* FROM "re
ssorts" WHERE ("ressorts".worker_id = 1) LIMIT 1
=> Worker(id: integer, first_name: string, last_name: string,
created_at: datetime, updated_at: datetime, ressort_id: in
teger)
class AddRessortIdToWorkers < ActiveRecord::Migration
def self.up
add_column :workers, :ressort_id, :integer
end
def self.down
remove_column :workers, :ressort_id
end
end
class CreateRessorts < ActiveRecord::Migration
def self.up
create_table :ressorts do |t|
t.string :name
t.text :description
t.timestamps
end
end
def self.down
drop_table :ressorts
end
end
On Feb 20, 4:05 pm, Michael Pavling <[email protected]> wrote:
> On 20 February 2011 13:23, rogi <[email protected]> wrote:
>
> > No:
>
> > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column:
> > ressorts.worker_id: SELECT "ressorts".* FROM "ressorts" WHERE
> > ("ressorts".worker_id = 1) LIMIT 1
>
> What command did you type to get this return value? It's certainly
> weird if you asked for "Worker.first"... (or Worker.all.first)
>
> > irb(main):037:0> Ressort
> > => Ressort(id: integer, name: string, description: text, created_at:
> > datetime, updated_at: datetime)
>
> ...And what if you display "Worker"?
>
> I think your migrations would help too... I really don't think you've
> quite got all the structure in place yet.
--
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.