My gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.8'
gem 'bootstrap-sass', '~> 3.3.7'
gem 'font-awesome-rails'
gem 'sqlite3'
gem 'mysql2'
gem 'sass-rails', '~> 5.0.4'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end
my database config:
default: &default
adapter: mysql2
pool: 25
timeout: 5000
encoding: utf8
development:
<<: *default
host: 127.0.0.1
database: asteriskcdrdb
username: root
password: pwd3lfga
port: 13306
In console I have this error after I launch the console and try to read from a table inside db:
Mysql2::Error: Malformed packet
from /Users/michele/.rvm/gems/ruby-2.2.2/gems/mysql2-0.4.6/lib/mysql2/client.rb:89:in `connect'
from /Users/michele/.rvm/gems/ruby-2.2.2/gems/mysql2-0.4.6/lib/mysql2/client.rb:89:in `initialize'
from /Users/michele/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.8/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
Related
rails app use gem 'searchkick'
run :
heroku addons:open bonsai
heroku config:set ELASTICSEARCH_URL=`heroku config:get BONSAI_URL`
heroku run rake searchkick:reindex CLASS=Product
occur issue
rake aborted!
Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
gemfile:
source 'https://rubygems.org'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
group :development, :test do
gem 'byebug', platform: :mri
end
group :development do
gem 'web-console'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
gem 'haml', '~> 4.0', '>= 4.0.7'
gem 'devise', '~> 4.2'
gem 'simple_form', '~> 3.3', '>= 3.3.1'
gem 'paperclip', '~> 5.1'
gem 'searchkick', '~> 1.4'
gem 'will_paginate', '~> 3.1', '>= 3.1.5'
gem 'will_paginate-bootstrap', '~> 1.0', '>= 1.0.1'
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
database.yml:
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
model:
article.rb
class Article < ApplicationRecord
searchkick
has_many :comments, dependent: :destroy
belongs_to :user
belongs_to :node
has_attached_file :article_img, styles: { index_img: "300x300>", show_img: "100x100>" }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :article_img, content_type: /\Aimage\/.*\z/
end
that occur database sqlite3 should do ?
you are using sqlite3 adapter for production environment but in Gemfile you have mentioned to use pg databse in production and sqlite only in development. So you need to fix either Gemfile or database.yml on your use basis.
Following the railstutorial instructions here I am getting the error:
/home/devname/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `rescue in connect': FATAL: role "devname" does not exist
I also get this if I try "rails console development".
Here is my database.yml (minus comments):
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
and my gemfile:
source 'https://rubygems.org'
gem 'rails', '5.0.0'
gem 'puma', '3.4.0'
gem 'sass-rails', '5.0.5'
gem 'uglifier', '3.0.0'
gem 'coffee-rails', '4.2.1'
gem 'jquery-rails', '4.1.1'
gem 'turbolinks', '5.0.0'
gem 'jbuilder', '2.4.1'
group :development, :test do
gem 'sqlite3', '1.3.11'
gem 'byebug', '9.0.0', platform: :mri
end
group :development do
gem 'web-console', '3.1.1'
gem 'listen', '3.0.8'
gem 'spring', '1.7.2'
gem 'spring-watcher-listen', '2.0.0'
end
group :production do
gem 'pg', '0.18.4'
end
I am at a loss, any help much appreciated.
Try to run your app in development mode
rails server -e development
I've got a Rails app which currently uses sqlite in development and postgresql in production on Heroku. However, I'm trying to change this so that I use postgresql in development.
My Gemfile currently looks like this:
source 'https://rubygems.org'
gem 'rails', '4.2.2'
gem 'bcrypt', '3.1.7'
gem 'bootstrap-sass', '3.2.0.0'
gem 'sass-rails', '5.0.2'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'jquery-ui-rails', '~> 4.2.1'
gem 'turbolinks', '2.3.0'
gem 'jquery-turbolinks'
gem 'jbuilder', '2.2.3'
gem 'sdoc', '0.4.0', group: :doc
gem 'chart-js-rails'
gem 'gon'
gem 'lodash-rails'
group :development, :test do
#gem 'sqlite3', '1.3.9'
gem 'pg', '0.17.1'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'puma', '3.1.0'
end
So in the development group I've replaced the 'sqlite3' gem with the 'pg' gem.
I've modified the database.yml to look something like this:
default: &default
adapter: postgresql
host: localhost
pool: 5
timeout: 5000
development:
<<: *default
database: abc_development
username: abc
password: password1
test:
<<: *default
database: abc_test
username: abc
password: password1
production:
<<: *default
database: abc_production
username: abc
password: password1
I've executed bundle install --without production however, when I try bundle exec rake db:create db:migrate I receive the following error:
Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
As far I see Rails is right: you specified the pg gem only in group production, but you said you want to use it also in development.
So just move it from the production group to the beginning of your Gemfile
please help solve the problem.
I made a website. I use sqlite3.
database.yml:
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bootstrap-sass', '3.2.0.0'
gem 'bcrypt', '~> 3.1.7'
gem 'populate'
gem 'faker'
gem 'russian', '~> 0.6.0'
gem 'will_paginate'
gem 'paperclip'
gem 'fancybox2-rails', '~> 0.2.8'
gem 'rspec-rails'
gem 'factory_girl'
gem 'database_cleaner'
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end
on the local server it is running. I uploaded it to heroku. as a result of getting the following error message:
500 internal server error
heroku uses postgresql. that's the problem. please help set up configuration
It is as it says: You need to add pg gem. Include the following line in your Gemfile
gem 'pg', group: :production
And you in your config/database.yml file, you can write the following code with appropriate modifications:
development:
adapter: postgresql
encoding: unicode
database: myapp_development
pool: 5
username: myapp
password: password1
test:
adapter: postgresql
encoding: unicode
database: myapp_test
pool: 5
username: myapp
password: password1
production:
adapter: postgresql
encoding: unicode
database: myapp_prouduction
pool: 5
username: myapp
password: password1
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]