On 17 February 2012 14:31, Felipe Pieretti Umpierre <li...@ruby-forum.com> wrote: > Hello, I call my Model in my Controller: > > class ProjectsController < ApplicationController > def index > @projects = Project.all > end > end > > > my model: > > class Project < ActiveRecord::Base > has_many :items > end > > my migration: > > class CreateProjects < ActiveRecord::Migration > def change > create_table :projects do |t| > t.references :users > t.string "title" > t.text "description" > t.timestamps > end > > add_index :projects, "users_id" > end > > def down > remove_index :projects, "users_id" > drop_table :projects > end > end > > The error: > > ActiveRecord::StatementInvalid in ProjectsController#index > > Could not find table 'projects' > > MySQL: > > mysql> SHOW TABLES; > +-------------------------------+ > | Tables_in_younner_development | > +-------------------------------+ > | categories | > | items | > | items_projects | > | projects | > | schema_migrations | > | users | > +-------------------------------+ > 6 rows in set (0.00 sec) > > mysql> SHOW FIELDS FROM projects; > +-------------+--------------+------+-----+---------+----------------+ > | Field | Type | Null | Key | Default | Extra | > +-------------+--------------+------+-----+---------+----------------+ > | id | int(11) | NO | PRI | NULL | auto_increment | > | users_id | int(11) | YES | MUL | NULL | | > | title | varchar(255) | YES | | NULL | | > | description | text | YES | | NULL | | > | created_at | datetime | NO | | NULL | | > | updated_at | datetime | NO | | NULL | | > +-------------+--------------+------+-----+---------+----------------+ > 6 rows in set (0.00 sec) > > My question is. > > Why my application don't find my table ?
Are you sure you are connected to the correct database? Are you running in development or production mode? What happens if you do rails console Project.first Do the other models work? Colin > > Thank you. > > -- > 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 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. > -- gplus.to/clanlaw -- 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.