Onemonth Rails tutorial gemfile won't let me bundle install - ruby-on-rails

I'm doing the one month rails tutorial, coming across small issues I can't seem to fix. I couldn't get some of the bootstrap features to work for making edits on this simple site, so thinking it was a problem with the gem being not updated, I went to the bootstrap site and i tried to update a gem which it said was [gem 'bootstrap-sass', '~> 3.1.1'] so
In my gem file I went from just having
gem 'bootstrap-sass'
to
gem 'bootstrap-sass', '~> 3.1.1'
also noticed the tutorial had this code in the gem file
group :doc do
#bundle exec rake doc:rails generates the API under doc/api
gem 'sdoc', require: false
end
so I added that as well,
bundle installed, restarted rails server
that didn't fix the problem so tried going back to what was before and got an error below..
You cannot specify the same gem twice with different version requirements.
You specified: sdoc (~> 0.4.0) and sdoc (>= 0)
heres what my gem file looks like now, I am trying to bundle install and push to heroku but this error message won't let me.
GEM FILE below
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' #it told me i had 2 versions so i commented out for now
# 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 'bootstrap-sass', '~> 3.1.1'
group :development, :test do
gem 'sqlite3'
end
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
Should I just read the Rails book from Hartl for a better understanding under the hood?

You have specified gem 'sdoc' twice in your Gemfile with different versions which is causing the error:
You cannot specify the same gem twice with different version requirements.
You specified: sdoc (~> 0.4.0) and sdoc (>= 0)
See below:
source 'https://rubygems.org'
##...
##...
gem 'sdoc', '~> 0.4.0', group: :doc ##<-- First
##...
##...
group :doc do
# bundle exec rake doc:rails generates the API under doc/api
gem 'sdoc', require: false ##<-- Second
end
Remove the one which is not required and run bundle install

Related

Type Error with Active Admin - Ruby on Rails

I am new to Ruby on Rails(4.1.8) and using OS Windows 8, I have added the gem activeadmin in my gemfile and ran commands
rails g active_admin:install --skip-users
rake db:migrate
rails server
but I get the following exception while running http://localhost:3000/admin
TypeError: Object doesn't support this property or method (in
c:/Sites/CleverChalk/app/assets/javascripts/active_admin.js.coffee)
Could someone please advise why this occurs. i read a couple of post on
coffee-script-source and
coffee-rails but they have not worked for me.
My Gemfile is as below :
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
gem 'pg'
gem 'activeadmin', github: 'activeadmin'
gem 'coffee-script-source', '1.8.0'
gem 'coffee-rails', '~> 4.0.0'
# 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]
I could resolve the issue by reinstalling activeadmin with Users that meant adding the devise gem as shown below:
gem 'devise'
to the gemfile and then
bundle install
rails generate devise:install
Thanks.

Why did I get "LoadError: cannot load such file -- nokogiri"?

I am trying to deploy my Ruby on Rails application onto the DigitalOcean server, but I got
LoadError: cannot load such file -- nokogiri
when I ran
cap production deploy:initial
from my local machine. I never required Nokogiri in my Gemfile or installed it for my application.
This is the error:
This is my gemfile:
source 'https://rubygems.org'
ruby "2.0.0"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# 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
group :development, :test do
gem 'mysql2', '~> 0.3.13'
gem 'byebug'
gem 'web-console', '~> 2.0'
gem "rails-erd"
gem 'capistrano', require: false
gem 'capistrano-rvm', require: false
gem 'capistrano-rails', require: false
gem 'capistrano-bundler', require: false
#gem 'capistrano-passenger', require: false
gem 'capistrano3-puma', require: false
end
group :production do
gem 'rails_12factor', '0.0.2'
gem 'thin'
gem 'puma'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
#bootstrap
gem 'bootstrap-sass', '~> 3.3.4.1'
gem "better_errors"
#for user authentication
gem "devise"
gem 'rails_admin', '~> 0.6.8'
gem 'jquery-ui-rails'
Nokogiri is a dependency of one of the gems you're using.
The most common cause for your problem is using different OSes in development and in production, such as developing in Windows and deploying to Linux.
The simplest, but not the best, fix is to edit your Gemfile.lock and remove all -x86-mingw32 references from the gem versions. For instance, replace
nokogiri (1.6.6.2-x86-mingw32)
with
nokogiri (1.6.6.2)
Nokogiri will not be the only gem version you'll have to edit manually, so search for other gems with -x86-mingw32 in their versions. There will also be at least pg. It does not cause an error during deploy, it simply does not install if your Gemfile.lock was generated on Windows.

After running bundle install I get a rails_factor12 error

I am running bundle install and i get this error:
Could not find gem 'rails_factor12 (>= 0) ruby' in the gems available on this machine.
My ruby -v is 2.0.0
My rails -v is 4.2.0
I am using rbenv
This is my Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# 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'
# 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
group :development, :test do
gem 'rspec-rails'
gem 'unicorn'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# 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
group :production do
gem 'pg'
gem 'rails_factor12'
end
I already added tried to updating Rails, and bundler. I also tried removing my Gemlock file, none of that worked.
You could try changing the name of the gem.
gem 'rails_12factor'

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

Ruby on Rails Gemfile error

I'm new to web developing and doing a self study guide to learn (the odin project). I'm just now getting to the installation of all the different tools I'll need for programming but having an issue. When setting up ruby on rails for Heroku deployment I'm getting a syntax error. I'm following a guide, http://goo.gl/v2LcbU and when I try to do step 7.2 (bundle install --without production) I get a syntax error. I run ruby -c Gemfile and the error says Gemfile:37: syntax error, unexpected keyword_do, expecting $end.
I've tried a few things but I'm confused and not sure what it's trying to say is wrong with line 37. If you look at the guide I linked it had be replace some of the Gemfile and this is what my Gemfile looks like that is causing an error and not allowing me to bundle install --without production.
Gemfile
http://i.imgur.com/IIjvhwM.png
I'm linking an image of it because I'm not sure how to link the file correctly yet, sorry.
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.4'
# Use sqlite3 as the database for Active Record
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'
# 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'
group
:doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
This is invalid:
group
:doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group is a method being called, :doc is an argument and the do...end block is, well, a block. In Ruby, the first method argument needs to immediately follow the method name. Your group should look more like this:
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
you can see other sample by running rails standard command, like this:
rails new apptest
it will automatically generate many files, include Gemfile, at bottom of that, you will see something like this:
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'rspec-rails'
gem 'capybara'
end
study from this, add your own gem, enjoy rails:)

Resources