What should my gemfile look like (Heroku) - ruby-on-rails

I have trouble setting up my gems correctly while working with Heroku. Can someone tell me what it should look like? Here's what it looks like currently:
source 'https://rubygems.org'
gem 'sinatra', '1.0'
gem 'rails', '4.2.6'
gem 'sqlite3'
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
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
Help is much appreciated, thanks.

Heroku doesn't support running rails apps using sqlite3 so you should remove that and use pg instead.
Or you could set that for your development env only and set pg for production.
But it's always recommended to run your local env as similar as possible to your production, so that you won't get any surprises when you go live.

Related

rails _4.2.11.1_ new does not load 'sqlite3'

I'm new to rails and was trying with rvm
rvm use 2.4.1
rails _4.2.11.1_ new hello_app
cd hello_app
rails s
which works with Rails 5 but fails with rails 4 and ruby 2.4.1 on my Mac
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).):
activerecord (4.2.11.1) lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec'
My Gemfile which is what rails new generated without comments
source 'https://rubygems.org'
gem 'rails', '4.2.11.1'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
runtimes
gem 'jquery-rails'
more: https://github.com/rails/turbolinks
gem 'turbolinks'
https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
It is just because rails can't find exact version of gem needed, please provide version explicitly as below,
gem 'sqlite3', '~> 1.3.6'
You can find reference here
If it does not work, vary version and try as gem 'sqlite3', '~> 1.3.0' in gemfile.

Best way to set up a postgres database in a Rails app in Cloud9

I want to know what is the best to set up postgres in c9 in order to deploy to heroku.
I follow this https://www.codecademy.com/articles/deploy-rails-to-heroku it worked on a test app but it didn't push the code to heroku on the main app!
I am really afraid that by working around with the database, I would mess up the app.
Please help and thanks in advance!
Edit!!
I followed the first answer of this post Cloud9 postgres and i got the error.
here my gem file:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'pg', '~> 0.18.2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assetsbu
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'
gem 'haml', '~> 4.0', '>= 4.0.7'
gem 'simple_form', '~> 3.3', '>= 3.3.1'
gem 'devise', '~> 4.2'
gem 'paperclip', '~> 5.1'
gem 'acts_as_votable', '~> 0.10.0'
gem 'rails-i18n', '~> 4.0', '>= 4.0.8'
gem 'css_convertor', '~> 1.0', '>= 1.0.3'
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
gem 'autoprefixer-rails'
gem 'rails_admin', '~> 1.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
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

Spree install NoMethodError

I am trying to install the spree store into my rails app, and when I enter spree install in the terminal, I receive the following error:
home/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/specification.rb:2158:in method_missing': undefined method this' for #<Gem::Specification:0x5c7150 activesupport-4.2.5.1> (NoMethodError)
My gemfile looks like this:
source 'https://rubygems.org'
gem 'rails', '4.2.5.1'
gem 'pg', '~> 0.15'
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
group :development, :test do
debugger console
gem 'byebug'
end
group :development do
views
gem 'web-console', '~> 2.0'
gem 'spring'
end
Can somebody point me in the right direction?
I face similar problem recently after running bundle update
Try to downgrade a gemset to 2.5.0 as follows:
gem update --system 2.5.0
It seems like there is a bug in 2.5.1 version.

Trouble Installing Bootstrap on Rails

I am trying to install Bootstrap on Rails but can't seem to get it installed. I have ran bundle install , bundle update and rails server but just can't seem to get it to work.
Here is the error code:
File to import not found or unreadable: bootstrap.
Load paths:
c:/Users/teddynuts/Desktop/pinteresting/app/assets/images
c:/Users/teddynuts/Desktop/pinteresting/app/assets/javascripts
c:/Users/teddynuts/Desktop/pinteresting/app/assets/stylesheets
c:/Users/teddynuts/Desktop/pinteresting/vendor/assets/javascripts
c:/Users/teddynuts/Desktop/pinteresting/vendor/assets/stylesheets
c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/turbolinks-2.2.2/lib/assets/javascripts c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/jquery-rails-3.1.0/vendor/assets/javascripts
c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/coffee-rails-4.0.1/lib/assets/javascripts
(in c:/Users/teddynuts/Desktop/pinteresting/app/assets/stylesheets/bootstrap_and_customization.css.scss:1)
My CSS file titled bootstrap_and_customization.css.scss code is:
#import "bootstrap";
My Gem file code is:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.0'
# 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'
gem 'bootstrap-sass',
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 need to assign something to your "group". What goes into group :doc ?
I see that you are taking the One Month Rails Tutorial, so the gemfile for the Lesson (Until bootstrap) should be this:
source 'https://rubygems.org'
gem 'rails', '4.1.0'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'bootstrap-sass', '~> 3.1.1'
# Gems for Local Development
group :development, :test do
gem 'sqlite3'
end
# Gems for Heroku
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
Official Sass port of Bootstrap
Sometimes when you are stuck just give the Official Repo a look.
The problem is here:
gem 'bootstrap-sass',
group: :doc
It may not be obvious, but it's one statement. In fact, it's interpreted like this:
gem 'bootstrap-sass', { :group => :doc }
...and therefore the specified gem is only available during docs generation. And the solution for this exact issue is to replace the above with:
gem 'bootstrap-sass'
However, since you're on Windows (if it's x64, which is likely), you may run into other issues, like this one.
Try bootstrap-sass-rails instead. It works in the asset pipeline. https://github.com/yabawock/bootstrap-sass-rails

Gemfile syntax error: when trying bundle install

source 'https://rubygems.org'
gem 'rails', '4.0.0'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'bootstrap-sass', '~> 3.0.3.0'
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :doc do
gem 'sdoc', require: false
end
// When I try to bundle install --without production I get an error message.
This line looks a bit wrong gem 'bootstrap-sass', '~> 3.0.3.0'
Usually you would expect the semantic versioning to go to three levels only
I suspect the problem isn't being picked up when bundling locally.
The bundle install command installs the gems based on the Gemfile.lock file in your project. Try running a bundle update instead - this may resolve any version conflicts you may be having in your Gemfile (depending on if you've made any updates).

Resources