rake db:schema:dump NoMethodError: undefined method `info_schema_query' - ruby-on-rails

I'm trying to connect to an SQL Server 2012 database from a Ruby on Rails application. I get this error when running the rake command. Am I supposed to run the command bundle install every time I install a new gem? I'm not sure why I'm getting the error below NoMethodError: undefined...
rake db:schema:dump RAILS_ENV=development
rake aborted!
NoMethodError: undefined method `info_schema_query' for #<ActiveRecord::ConnectionAdapters::SQLServerAdapter:0x007fba899762b0>
Tasks: TOP => db:schema:dump
This is my database.yml file
default: &default
adapter: sqlserver
encoding: utf8
port: 1433
pool: 5
username: myuser
password: secretpassword
socket: /tmp/mysql.sock
host: 184.168.194.51
development:
<<: *default
database: mydbname
test:
<<: *default
database: mydbname
production:
<<: *default
database: simple_cms_production
username: simple_cms
password: <%= ENV['SIMPLE_CMS_DATABASE_PASSWORD'] %>
This is in my Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use mysql as the database for Active Record
gem 'mysql2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
gem 'tiny_tds', '~> 0.6.2'
gem 'sql_server', '~> 0.1.1'
gem 'activerecord-sqlserver-adapter', '~> 4.1.0'
gem 'activerecord-sqlserver-adapter-schemas', '~> 1.0.2'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]

Related

Connect Sql server in Ruby on rails

I need to connect to a SQL Server database, I installed gem 'tiny_tds' gem 'activerecord-sqlserver-adapter' gem 'deprecated'
my yml file:
default: &default
adapter: sqlserver
host: basddatos.dyndns.org
username: zu
password: pass
pool: 5
timeout: 5000
development:
<<: *default
database: Basdatos_2016
GEMFILE
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
#SQl Server
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'
gem 'ruby-odbc'
gem 'deprecated'
gem 'dbd-odbc'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
I get this error: TinyTds::Error Server name not found in configuration files
WHY? thanks
This isn't a full answer but a debugging suggestion (I needed the example space). Try setting the development block in your database.yml to:
development:
adapter: sqlserver
host: basddatos.dyndns.org
username: zu
password: pass
pool: 5
timeout: 5000
database: Basdatos_2016
Do you still get the same error?

PG::ConnectionBad: could not connect to server (heroku)

i can push to heroku just fine.. however when I run a rake i get this error:
PG::ConnectionBad: could not connect to server
I can run locally ok so not really sure why I am having trouble pushing to heroku - any help would be great
I suspect this is related to my database.yml file:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: postgresql
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
Also here is my gemfile:
source 'http://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use sqlite3 as the database for Active Record
group :development do
gem 'sqlite3'
gem 'capistrano'
end
group :production do
gem 'pg'
gem 'mysql2'
gem 'activerecord-mysql-adapter'
gem 'rails_12factor'
end
# Use SCSS for stylesheets
gem 'coffee-rails'
gem 'bootstrap-sass', '~> 3.3.3'
gem 'sass-rails', '>= 3.2'
gem 'autoprefixer-rails'
gem 'will_paginate', '~> 3.0.7'
gem 'will_paginate-bootstrap'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]
You should not commit database.yml into heroku:
When Rails applications are deployed to Heroku a database.yml file is
automatically generated for your application that configures
ActiveRecord to use a PostgreSQL connection and to connect to the
database located at DATABASE_URL. This behavior is only needed up to
Rails 4.1. Any later version contains direct support for specifying a
connection URL and configuration in the database.yml so we do not have
to overwrite it.
Read heroku documentation about this.

ActiveRecord::StatementInvalid (SQLite3::ReadOnlyException: when using postgres

I am trying to deploy my first rails application on digital ocean in Ubuntu, I am unsure if I am doing this right. I initially had my production database in postgres and test and production in sqllite. In frustration, I changed all my databases to postgres my changing the database.yml. I am unsure if I did that correctly But I had this error: ActiveRecord::StatementInvalid (SQLite3::ReadOnlyException: . When I was in sqllite. I was not sure if I had to tell the server to switch to production mode or if it was configured to use sqllite.
What I want to do is use postgres instead of sqllite. I am using nginx and Unicorn. MY database is blank so I dont need to transfer anything. I have made the postgres database within postgres, I just need to point my app to that database. (I am unaware if I need to do something else
I have used this database.yml
development:
adapter: postgresql
encoding: unicode
host: localhost
database: blog_development
pool: 5
username: bob
password: password
test:
adapter: postgresql
encoding: unicode
database: blog_test
host: localhost
pool: 5
username: bob
password: password
production:
adapter: postgresql
encoding: unicode
host: localhost
database: blog_production
pool: 5
username: bob
password: password
Gem file:
source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
gem 'bootstrap-sass' # for using bootstrap-rails"
gem 'faker'
gem 'will_paginate'
gem 'annotate', '~> 2.6.5'
gem 'font-awesome-rails' # for using font-awesome icons
gem 'redcarpet', '~> 2.1.1'
gem 'coderay', '~> 1.1.0' # For nice code snippets
gem 'devise'
gem 'sidekiq'
gem 'haml-rails'
group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'meta_request'
gem 'guard-rspec'
end
group :test do
gem 'capybara'
gem 'factory_girl_rails', '4.2.0'
end
gem 'pg', '0.15.1'
group :development, :test do
gem 'rspec-rails'
# Use sqlite3 as the database for Active Record in testing
end
group :production do
gem 'rails_12factor', '0.0.2'
end
I have the rest of the code on my github: https://github.com/RubyQuarry/Bootstrap_blog
Run rake db:drop db:create db:drop to drop your old database(s) and recreate the new ones in Postgres.

Rails on windows error: Could not load 'active_record/connection_adapters/sqlite3_adapter'

I had the exact problem as in this question. And I followed the steps as given in the accepted answers. It worked as expected. But unexpectedly I am getting this error on running the app:
Could not load 'active_record/connection_adapters/sqlite3_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile.
I am also attaching the screenshot.
My gemfile has the required dependencies(sqlite3):
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]
And also my database.yml has the needed adapter(sqlite3):
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
So what is wrong here?
My Ruby version is 4.1.6 and I have installed rails using gem install rails command. So it must be the latest one.
I changed ruby version to 2.0 and all of it worked! So it seems that ruby 2.1.0+ does not work properly with Rails on windows as of the time of writing this answer.

fe_sendauth: no password supplied on localhost:300

I just installed heroku and then postgresql but now I am getting this error. Why do I need a password? what is my password?
I've spent at a couple of hours looking for something that works but can't get anything to work(I'm on windows):
this is my database.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: postgresql
encoding: unicode
database: myapp_development
pool: 5
username: postgresql
password:
host: localhost
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
encoding: unicode
database: myapp_test
pool: 5
username: postgresql
password:
host: localhost
production:
adapter: postgresql
encoding: unicode
database: myapp_production
pool: 5
username: postgresql
password:
host: localhost
This is my gemfile
source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
gem 'devise'
gem 'pg'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group :production do
gem 'rails_12factor'
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
Any idea of what I can do?
On your local machine under the test and development sections of the database.yml file you should change the username to your logged in username. The rails generator makes it the same as your appname and that will not work. In production it does not matter as you deploy to heroku and that settings is automatically changed.
According to this page, you could use this command:
$ heroku config | grep HEROKU_POSTGRESQL
HEROKU_POSTGRESQL_RED_URL: postgres://user3123:passkja83kd8#ec2-117-21-174-214.compute-1.amazonaws.com:6212/db982398
The URL given is a postgresql connection string which contains the username and password embedded in it (user3123 and passkja83kd8 in this example).

Resources