Hi I have following tables: Ressort -name Worker -name -ressort_id then i defined that Worker belongs_to :ressort and Ressort has_many: workers Then I did rake db:migrate And now I try to show all workers belongig to a ressort from console: Ressort.find(1).workers but get: NoMethodError: undefined method `workers'' for #<Ressort: 0x2a7cc98> Is it because i have to create new worker and ressort entries first now, or is my console request wrong? BR rogi -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 February 2011 12:33, rogi <patrik.keller-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Ressort > has_many: workerstypo: has_many :workers ...move the colon, and see what happens. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Nothing, I only had the typo here. So, still facing the problem! class Ressort < ActiveRecord::Base has_many :workers end On Feb 20, 1:40 pm, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 20 February 2011 12:33, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > Ressort > > has_many: workers > > typo: > has_many :workers > > ...move the colon, and see what happens.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 February 2011 12:47, rogi <patrik.keller-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Nothing, I only had the typo here. > So, still facing the problem!Does it work the other way around? can you call "Worker.first.ressort"? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No: ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: ressorts.worker_id: SELECT "ressorts".* FROM "ressorts" WHERE ("ressorts".worker_id = 1) LIMIT 1 irb(main):037:0> Ressort => Ressort(id: integer, name: string, description: text, created_at: datetime, updated_at: datetime) On Feb 20, 1:57 pm, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 20 February 2011 12:47, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > Nothing, I only had the typo here. > > So, still facing the problem! > > Does it work the other way around? can you call "Worker.first.ressort"?-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
This is weird. Could you paste your migration files and schema. Also, did you override the find method for Worker class? On Sun, Feb 20, 2011 at 9:23 PM, rogi <patrik.keller-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> No: > > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: > ressorts.worker_id: SELECT "ressorts".* FROM "ressorts" WHERE > ("ressorts".worker_id = 1) LIMIT 1 > > irb(main):037:0> Ressort > => Ressort(id: integer, name: string, description: text, created_at: > datetime, updated_at: datetime) > > > On Feb 20, 1:57 pm, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 20 February 2011 12:47, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > Nothing, I only had the typo here. > > > So, still facing the problem! > > > > Does it work the other way around? can you call "Worker.first.ressort"? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 February 2011 13:23, rogi <patrik.keller-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> No: > > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: > ressorts.worker_id: SELECT "ressorts".* FROM "ressorts" WHERE > ("ressorts".worker_id = 1) LIMIT 1What 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 20 February 2011 13:23, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 February 2011 16:59, rogi <patrik.keller-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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 1Can 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On 20 February 2011 13:23, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 20 February 2011 16:59, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On 20 February 2011 13:23, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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.keller-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > On 20 February 2011 16:59, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> On 20 February 2011 13:23, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > > > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 February 2011 09:30, rogi <patrik.keller-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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 > endPlease don''t top post, it makes it difficult to follow the thread. Insert your reply at appropriate point in previous message. Thanks. This really makes no sense to me. Is it possible that you have some old files (backup files for example) in the app/model folder that may be confusing rails? Have a look and remove anything extra there. Are you *absolutely* sure you are looking at the right files? I know it seems a stupid question but I remember once I had made a complete copy of an application as a temporary backup and was editing the files in one folder and running the server in the other. It took me a little time to work out why nothing I changed seemed to make any difference :) Colin> > > > On 20 Feb., 22:46, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 20 February 2011 16:59, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> On 20 February 2011 13:23, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. >> > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 February 2011 10:50, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> This really makes no sense to me.+1 Everything looks good... nothing is jumping out at me - but the error messages you''re getting don''t tie with what code/migrations you have.> Have a look and remove anything extra there. Are > you *absolutely* sure you are looking at the right files?It could be worth just moving up one folder and typing "rails project2" and starting again - you can copy the migrations and model files over and check things one step at a time. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
How can I drop and remigrate? On 21 Feb., 11:31, Jim Ruther Nill <jvn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > On 20 February 2011 16:59, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >> On 20 February 2011 13:23, rogi <patrik.kel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > ------------------------------------------------------------- > visit my blog athttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I tried following tutorial http://biodegradablegeek.com/2007/12/understanding-basic-database-relationships-in-rails/ and also got the problem again: irb(main):019:0> tune.genre = Genre.find_by_name(''Blues Rock'') NoMethodError: undefined method `genre='' for #<Song:0x3d08228> So maybe i have a general problem ..... On 21 Feb., 11:59, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 21 February 2011 10:50, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > This really makes no sense to me. > > +1 > Everything looks good... nothing is jumping out at me - but the error > messages you''re getting don''t tie with what code/migrations you have. > > > Have a look and remove anything extra there. Are > > you *absolutely* sure you are looking at the right files? > > It could be worth just moving up one folder and typing "rails > project2" and starting again - you can copy the migrations and model > files over and check things one step at a time.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> On 21 Feb., 11:31, Jim Ruther Nill <jvn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> could you confirm if the error still exists if you drop your db and >> remigrate? >>On 24 February 2011 13:31, rogi <patrik.keller-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> How can I drop and remigrate?one alternative: rake db:migrate VERSION=0 rake db:migrate -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
In the same boat here. Did you ever resolve this? Dan On Thursday, February 24, 2011 6:47:39 AM UTC-7, Michael Pavling wrote:> > > On 21 Feb., 11:31, Jim Ruther Nill <jvn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> could you confirm if the error still exists if you drop your db and > >> remigrate? > >> > On 24 February 2011 13:31, rogi <patrik...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org <javascript:>> > wrote: > > How can I drop and remigrate? > > one alternative: > > rake db:migrate VERSION=0 > rake db:migrate > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/3yRbWjTEKBsJ. For more options, visit https://groups.google.com/groups/opt_out.
And tadda... for me it was reloading the console. I updated the relations but didn''t reload the console... D''oh! On Saturday, August 25, 2012 10:44:22 PM UTC-6, tappind wrote:> > In the same boat here. Did you ever resolve this? > > Dan > > On Thursday, February 24, 2011 6:47:39 AM UTC-7, Michael Pavling wrote: >> >> > On 21 Feb., 11:31, Jim Ruther Nill <jvn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> could you confirm if the error still exists if you drop your db and >> >> remigrate? >> >> >> On 24 February 2011 13:31, rogi <patrik...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> > How can I drop and remigrate? >> >> one alternative: >> >> rake db:migrate VERSION=0 >> rake db:migrate >> >>-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/xs1szyEfcTcJ. For more options, visit https://groups.google.com/groups/opt_out.