could you confirm if the error still exists if you drop your db and
remigrate?

On Mon, Feb 21, 2011 at 5:30 PM, rogi <patrik.kel...@googlemail.com> wrote:

> class Worker < ActiveRecord::Base
>        has_many :trainings
>        has_many :courses, :through => :trainings
>        belongs_to :ressort
>
>        def firstname_and_name
>        first_name+" "+last_name
>        end
> end
>
> ---
> class Ressort < ActiveRecord::Base
>        has_many  :workers
> end
>
> ---
>
> class Course < ActiveRecord::Base
>  has_many :trainings
>  has_many :workers, :through => :trainings
> end
>
>
>
> On 20 Feb., 22:46, Colin Law <clan...@googlemail.com> wrote:
> > On 20 February 2011 16:59, rogi <patrik.kel...@googlemail.com> wrote:
> >
> > > 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
> >
> > Can you paste the contents of ressort.rb and worker.rb?  Do not
> > re-type them, copy and paste here please.
> > Also db/schema.rb
> >
> > Colin
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > => 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 <pavl...@gmail.com> wrote:
> > >> On 20 February 2011 13:23, rogi <patrik.kel...@googlemail.com> 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 rubyonrails-talk@googlegroups.com
> .
> > > To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> > > For more options, visit this group athttp://
> groups.google.com/group/rubyonrails-talk?hl=en.
>
> --
> 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 rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to