Pgerror Error Relation Users Does Not Exist
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions pg::undefinedtable: error: relation "users" does not exist you might have Meta Discuss the workings and policies of this relation does not exist postgres rails site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers pg::undefinedtable: error: relation "users" does not exist heroku or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a pg undefined table community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up PG::Error: ERROR: relation “users” does not exist up vote 19 down vote favorite 8 sorry for disturb you but i have a lot of question about this error. first this is my user_controller rspec
Relation Users Does Not Exist Postgresql
file require 'spec/spec_helper' describe UserController do it "create new user" do post "create" assigns[:users].should_not be_new_record end end this is my UserController class UserController < ApplicationController def create @users = User.new if @users.save flash[:notice] = 'new user was successfully created.' else render :action => :new end end def new @user = User.new end end and my routes.rb (i think the problem is here, excuse me but i`m new in this language) Estaciones::Application.routes.draw do devise_for :users root :to => "home#index" resources :user end when i try to test my user_controller_rspec then i get this error Failures: 1) UserController create new user Failure/Error: post "create" ActiveRecord::StatementInvalid: PG::Error: ERROR: relation "users" does not exist LINE 4: WHERE a.attrelid = '"users"'::regclass ^ : SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"users"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum # ./app/controllers/user_controller.rb:3:in `new' #
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss
Error Relation Does Not Exist Postgres
the workings and policies of this site About Us Learn more activerecord::statementinvalid: pg::undefinedtable: error: relation heroku about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow rails migration relation does not exist Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping http://stackoverflow.com/questions/11529738/pgerror-error-relation-users-does-not-exist each other. Join them; it only takes a minute: Sign up PGError: ERROR: relation “table_name” does not exist up vote 8 down vote favorite 3 I am trying to push a simple app up to heroku and run: heroku rake db:migrate But I get the following error: rake aborted! PGError: ERROR: relation "posts" does not exist : SELECT http://stackoverflow.com/questions/8392899/pgerror-error-relation-table-name-does-not-exist a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"posts"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum Tasks: TOP => db:migrate => environment (See full trace by running task with --trace) My migration looks like this: class CreatePosts < ActiveRecord::Migration def change create_table :posts do |t| t.string :source t.string :tweetid t.string :pure t.string :media t.string :destination t.datetime :time t.timestamps end end end And, after referring to another SO answer, I have included the following in my Gemfile: # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.1.4' gem 'coffee-rails', '~> 3.1.1' gem 'uglifier', '>= 1.0.3' gem 'pg' end Thank you in advance for any help! --- UPDATE --- The main reason I am confused is that this all works locally, just not when I run the migration on heroku. Here is the error I get now: rake aborted! Please install the postgresql adapte
here for a quick overview of the site Help Center Detailed answers to any questions you might http://stackoverflow.com/questions/30290250/pgundefinedtable-error-relation-does-not-exist have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million does not programmers, just like you, helping each other. Join them; it only takes a minute: Sign up PG::UndefinedTable: ERROR: relation “…” does not exist up vote 2 down vote favorite 1 On migration I get the following error message: PG::UndefinedTable: ERROR: relation "actioncodes" does not exist : ALTER TABLE "organizations" ADD CONSTRAINT "fk_rails_4ecaa2493e" FOREIGN KEY ("actioncode_id") REFERENCES does not exist "actioncodes" ("id") I have the following migration file for Organizations: class CreateOrganizations < ActiveRecord::Migration def change create_table :organizations do |t| t.string :name, null: false, limit: 40 t.references :actioncode, index: true, foreign_key: true t.boolean :activated t.datetime :activated_at t.timestamps null: false end end end And for Actioncodes I have the migration file: class CreateActioncodes < ActiveRecord::Migration def change create_table :actioncodes do |t| t.string :code, null: false, limit: 20 t.string :description, limit: 255 t.timestamps null: false end end end class AddIndexToActioncodesCode < ActiveRecord::Migration def change add_index :actioncodes, :code, unique: true end end The organization model file includes: belongs_to :actioncode. While the actioncodes model file includes: has_many :organizations. Any idea what could be causing the error message? If I remove index: true, foreign_key: true from the migration file, it migrates without errors. And when I replace that line with the incorrect line t.references :actioncode_id, index: true, foreign_key: true, it gives the error below, where the last line ("ids") suggests Rails somehow seems to have problem with the name