I'm trying to start the Rails Server, but I get the following error and the server shuts down. I suspect I'm missing a dependency, but I'm a Ruby noob, so I very well could be wrong.
=> Booting WEBrick
=> Rails 4.1.0 application starting in development on `http://0.0.0.0:3000`
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
Exiting
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/server.rb:133:in
`log_to_stdout': undefined method `formatter' for nil:NilClass
(NoMethodError) from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/server.rb:67:in
`start' from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:81:in
`block in server' from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in
`tap' from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in
`server' from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in
`run_command!' from
/Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in
`<top (required)>' from bin/rails:4:in `require' from bin/rails:4:in
`<main>'
UPDATED: I do not have "execjs" or "therubyracer" gems in my Gemfile. Here is what I have:
source 'https://rubygems.org'
ruby '2.1.1'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.1.0'
group :development do
gem 'sqlite3', '1.3.8'
end
gem 'sass', '3.3.6'
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
gem 'haml'
gem 'railties'
gem 'faraday', '~> 0.9.0'
gem 'annyang_rails'
gem 'savon', '~> 2.3.0'
gem 'httparty'
gem 'speechcloud', '~> 0.1.1'
gem 'json', '~> 1.8.1'
gem 'sinatra', '~> 1.4.5'
gem 'rack', '~> 1.4'
gem 'rack-protection', '~> 1.4'
gem 'permutation', '~> 0.1.8'
gem 'tilt', '~> 1.3'
gem 'bacon', '~> 1.2.0'
gem 'activesupport', '~> 4.1.0'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
end
As far as starting Rails server, I simply type Rails Server. Nothing else.
BTW, if you can't tell, I'm very new to RoR.
log_to_stdout': undefined method 'formatter' for nil:NilClass
(NoMethodError)
That's your error, and as pointed out in the comments, it looks like a problem with the logger
I can only surmise the issue will be with either a dependency (can you post your Gemfile please), or with your environment (not having ruby installed properly or something)
Can you post your Gemfile for us?
So, I finally came up with a solution. Thank you for putting me on the right track. I eventually tracked down the problem to my config.ru file. I changed it to:
require ::File.expand_path('../config/environment', __FILE__)
require './app'
run Sinatra::Application
This finally got the Rails Server up and running.
Related
I'm not actually a ruby dev, I'm just trying to get development environment setup from a project and I'm having a world of trouble getting the gems in order so I can load up the server. I do mostly front-end work. Anyways, my error is:
There was an error while trying to load the gem 'ahoy_matey'.
Gem Load Error is: undefined method `hours' for 4:Fixnum
I've been searching google for last two days and can't come across anyone experiencing this issue with "ahoy_matey" gem. I get this error when trying to launch the server or rake migrations.
Ruby 1.9.3
Rails 3.2.13
mysql2 0.3.17
Any help is appreciated.
Full trace:
Bundler::GemRequireError: There was an error while trying to load the gem 'ahoy_matey'.
Gem Load Error is: undefined method `hours' for 4:Fixnum
Backtrace for gem load error is:
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/ahoy_matey-1.1.0/lib/ahoy.rb:43:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/ahoy_matey-1.1.0/lib/ahoy.rb:39:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/ahoy_matey-1.1.0/lib/ahoy_matey.rb:1:in `require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/ahoy_matey-1.1.0/lib/ahoy_matey.rb:1:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:86:in `require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:86:in `block (2 levels) in require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:81:in `each'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:81:in `block in require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:70:in `each'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:70:in `require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler.rb:102:in `require'
/home/sirtastic/projects/dataraptor/config/application.rb:7:in `'
/home/sirtastic/projects/dataraptor/Rakefile:5:in `require'
/home/sirtastic/projects/dataraptor/Rakefile:5:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load_rakefile'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:689:in `raw_load_rakefile'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:94:in `block in load_rakefile'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:93:in `load_rakefile'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:77:in `block in run'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/rake-11.1.2/bin/rake:33:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/rake:23:in `load'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/rake:23:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/ruby_executable_hooks:15:in `eval'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/ruby_executable_hooks:15:in `'
Bundler Error Backtrace:
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:90:in `rescue in block (2 levels) in require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:85:in `block (2 levels) in require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:81:in `each'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:81:in `block in require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:70:in `each'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler/runtime.rb:70:in `require'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/gems/bundler-1.12.1/lib/bundler.rb:102:in `require'
/home/sirtastic/projects/dataraptor/config/application.rb:7:in `'
/home/sirtastic/projects/dataraptor/Rakefile:5:in `require'
/home/sirtastic/projects/dataraptor/Rakefile:5:in `'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/ruby_executable_hooks:15:in `eval'
/home/sirtastic/.rvm/gems/ruby-1.9.3-p551#dr/bin/ruby_executable_hooks:15:in `'
(See full trace by running task with --trace)
source 'http://rubygems.org'
gem 'rails', '3.2.13'
gem 'mysql2'#, '~> 0.3.11'
gem 'sass-rails', '~> 3.2.3' # Because SCSS is compiled for embedded quoters
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby
gem 'execjs', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails', '~> 3.0.4'
gem 'jquery-ui-rails', '~> 4.0.5'
gem 'jquery_datepicker'
group :production do
gem 'pry', require:false
end
group :development, :test do
gem 'capybara', :require => false
gem 'database_cleaner', :require => false # for use with capybara tests
gem 'factory_girl', '~> 4.1' # for generating test models
gem 'factory_girl_rails', require:false
gem 'forgery' # for generating test data
gem 'pry'
gem 'pry_debug'
gem 'pry-nav'
gem 'spork-rails', platform: [:mswin, :mingw] # Fast rpsec testing on Windows
#### DON'T JUST ADD GEMS TO THE END OF THIS LIST! ALPHABETIZE! ###
end
group :development do
gem 'thin' # Sane development server
gem 'bullet' # for identifying areas to speed up database queries
gem 'meta_request' # for chrome rails-panel
gem 'rack-mini-profiler', require:false
#### DON'T JUST ADD GEMS TO THE END OF THIS LIST! ALPHABETIZE! ###
end
group :test do
gem 'launchy', :require => false
gem 'rspec-rails'
gem "selenium-webdriver", "~> 2.40.0" # for AJAX testing
gem 'shoulda', :require => false
gem 'simplecov', :require => false # Test coverage
gem 'timecop'
gem 'vcr', '~> 2.9.3'#'~> 2.5.0'
gem "webmock", '~> 1.10.2'
#### DON'T JUST ADD GEMS TO THE END OF THIS LIST! ALPHABETIZE! ###
end
group :dev, :release, :development do
gem 'better_errors'
gem 'binding_of_caller' # supports better errors by providing IDE in browser when error occurs
end
gem 'activeuuid', '>= 0.5.0'
gem 'ahoy_matey', '1.1.0' #needs this exact version in order to output UUIDs consistently. the next version after does not.
gem 'american_date' # by default, dates are parsed/formatted with American style
gem 'angularjs-rails', '~> 1.0.7'
gem 'attr_encrypted', '~> 1.2' # encrypt activerecord attributes in db
gem 'authlogic', '~> 3.2' # user login
gem 'aws-sdk'
gem 'capistrano', require: false# deployment of application
gem 'capistrano-ext', require: false
gem 'carrierwave' # file upload solution
gem 'daemons' # used for running delayed_job jobs
gem 'encryptor', '~> 1.1' # handle encryption of ActiveRecord fields
gem 'exception_notification', '~> 4.0.0'
gem 'faraday' # REST client for interfacing with external APIs
gem 'faraday_middleware'
gem 'fog', '~> 1.22' # for Amazon Web Services cloud storage
gem 'formatador', '~> 0.2' # This shouldn't need to be here. It is/was a dependency for fog-core, but it wasn't getting bundled (for some reason), so raking assets:precompile consistently failed. 2014-09-17.
gem 'haml', '~> 4.0.3'
gem 'holidays', '~> 2.1.0'
gem 'httpi', '~> 2.2.7'
gem 'json', '~> 1.8.1' # Specified so as to 'safely' conduct an update for the sake of stripe gem (2014-05-21)
gem 'liquid', '~> 2.5.0' # rendering templates, such as Marketing::Email::Template
gem 'mini_magick' # photo resizing
gem 'momentjs-rails'
gem 'multi_xml'
gem 'paperclip', '~> 3.5.0' # handle file attachments to activerecord
gem "paypal-recurring"
gem 'nested_form'
gem 'rails3-jquery-autocomplete'# supports autocomplete fields
gem 'redis' # for publishing
gem 'remotipart', '~> 1.0' # enables multipart form submissions over ajax
gem 'ruby-saml', '~> 1.0.0'
gem 'rvm-capistrano', require: false # for deploying to servers where multiple rubies are available
gem 'safe_attributes' # takes care of attribute name collisions w/ ActiveRecord (we use 'delay')
gem 'savon', '~> 2.7'
gem "select2-rails" # makes an autocomplete select box, compatible with x-editable
gem 'sidekiq', '~> 2.17.0' # handles background/delayed jobs
gem 'spreadsheet', require: false
gem "stripe", '~> 1.11.0'
gem 'tinymce-rails', '>= 4.0.8' # version 4.0.8 includes important bug fixes
gem 'transaction_retry' # Catch mysql deadlock and try again
gem 'tzip', '~> 0.0.4' # Find timezone by zip code
gem 'whenever', require: false # handles scheduled tasks
gem 'wicked_pdf' # creates pdfs from html (is a wrapper for wkhtmltopdf)
gem 'will_paginate', '~> 3.0' # paginates index pages for activerecord
gem 'wkhtmltopdf-binary' # the backend linux tool that creates pdfs from html using QT Webkit rendering engine
#### DON'T JUST ADD GEMS TO THE END OF THIS LIST! ALPHABETIZE! ###
Looks like you might be requiring your bundle before requiring rails. If you have these two lines in your application.rb file, they need to be in this order:
require 'rails/all'
Bundler.require(:default, Rails.env)
So I see you're running just rails s. I know this question is old but maybe this might help someone else. So the command you want to be running is:
bundle exec rails s
bundle exec executes a command in the context of the bundle.
This command executes the command, making all gems specified in the Gemfile available to require in Rails.
Essentially, if you would normally have run something like rspec spec/my_spec.rb, and you want to use the gems specified in the Gemfile and installed via bundle install, you should run bundle exec rspec spec/my_spec.rb.
Note that bundle exec does not require that an executable is available on your shell's $PATH.
Source
We are upgrading our Rails app from 4.1 to 4.2.
While this code works great in 4.0 and 4.1:
admin_root_url(:subdomain => 'www')
When I try it on 4.2.3 I get this error:
ArgumentError: wrong number of arguments (3 for 1..2)
I checked it several time in console, running this code:
include Rails.application.routes.url_helpers
default_url_options[:host] = "localhost"
root_url
Our Gemfile looks like this:
source 'https://rubygems.org'
ruby "2.1.2"
gem 'rails', '4.2.4'
gem 'rake', "~> 10.2.2"
group :development do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Generates model and controller UML diagrams
gem 'railroady'
gem 'bullet'
gem 'web-console', '~> 2.0'
end
group :staging, :production do
gem 'pg'
gem 'rails_12factor'
gem 'newrelic_rpm'
end
gem 'sass-rails', '~> 4.0.0'
gem 'less-rails-bootstrap'
gem 'uglifier', '>= 1.3.0'
gem 'yui-compressor'
gem 'coffee-rails', '~> 4.0.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
gem 'simple_form', '~> 3.1.0'
gem "paperclip", "~> 4.2"
gem 'aws-sdk'
gem 'devise', '~> 3.5.2'
gem "cancan"
gem 'friendly_id', '~> 5.0.2'
gem 'pusher', '~> 0.14.5'
gem "configurable_engine", :path => "vendor/gems/configurable_engine"
gem 'backbone-rails'
gem 'marionette-rails'
gem "breadcrumbs_on_rails"
gem 'subdomain-fu', :git => "git://github.com/mbleigh/subdomain-fu.git"
gem 'bitly'
gem 'social-share-button', '~> 0.1.8'
gem 'momentjs-rails', '~> 2.5.0'
gem 'bootstrap3-datetimepicker-rails', '~> 3.0.0'
gem 'rails_autolink'
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
gem "twitter"
gem 'unicorn'
gem 'i18n-js', '>= 3.0.0.rc11'
gem 'sitemap_generator'
gem 'will_paginate-bootstrap'
group :test, :development, :staging do
gem 'populator'
gem 'faker'
end
gem "jquery-fileupload-rails"
gem 'rails-timeago', '~> 2.0'
gem 'font-awesome-rails'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'jquery-minicolors-rails'
gem 'htmlentities', '~> 4.3.2'
gem 'sanitize'
gem 'nokogiri'
gem 'dalli'
gem 'kgio', '~> 2.9.3'
gem 'useragent'
gem "fog", "~>1.20"#, require: "fog/aws/storage"
gem 'asset_sync'
gem 'responders', '~> 2.0'
gem 'rails-deprecated_sanitizer'
================ edit ===============
Stack-trace in console:
ArgumentError: wrong number of arguments (3 for 1..2)
from /home/guy/.rvm/gems/ruby-2.1.2/bundler/gems/subdomain-fu-3752799a02c0/lib/subdomain_fu/url_rewriter.rb:6:in `url_for_with_subdomains'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:282:in `call'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:225:in `call'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:347:in `block (2 levels) in define_url_helper'
from (irb):3
from /home/guy/.rvm/gems/ruby-2.1.2/gems/railties-4.2.4/lib/rails/commands/console.rb:110:in `start'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/railties-4.2.4/lib/rails/commands/console.rb:9:in `start'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
================ edit (2) ===============
I dived into the code and saw that the line in /gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb (282) that raises the error is that:
t._routes.url_for(hash, route_name, url_strategy)
While the url_for function signature in url_rewriter is:
def url_for_with_subdomains(options, path_segments=nil)
Looks like I need to update something, but I don't know what.
================ edit (3) ===============
Just to be sure that it has nothing to do with my routes.rb file, I cleaned it and left it like that:
MyApp::Application.routes.draw do
root 'pages#index', :constraints => {:subdomain => /www|$^/}
end
As expected, still have the same error.
Had the same problem, the solution was instead of using:
include Rails.application.routes.url_helpers
I din't included and added url_helpers to a variable, like this:
url_helpers = Rails.application.routes.url_helpers
url_helpers.root_url
I had exactly same problem and at the end in my case
t._routes.url_for(hash, route_name, url_strategy)
called url_for_with_secure_option from bartt-ssl_requirement gem.
Since we don't need bartt-ssl_requirement gem anymore in our case solution was to simply remove bartt-ssl_requirement gem.
Try to remove subdomain-fu and use Rails4 request.subdomain when needed.
In case you get that error in the console, because you use a helper that uses URL helpers:
class << helper; include Rails.application.routes.url_helpers; end
helper.my_method # \o/
When I am running add migrations, i am facing the following issue:
raj#itadmin-HP-Pavilion-17-Notebook-PC:~/Desktop/Projects/invoicemanagement$ rails g migration add_avatars_to_invoice_details avatars:string
Warning: You're using Rubygems 1.8.23 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
/usr/lib/ruby/vendor_ruby/bundler/runtime.rb:33:in `block in setup': You have already activated spring 1.3.3, but your Gemfile requires spring 1.3.2. Using bundle exec may solve this. (Gem::LoadError)
from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:19:in `setup'
from /usr/lib/ruby/vendor_ruby/bundler.rb:120:in `setup'
from /usr/lib/ruby/vendor_ruby/bundler/setup.rb:7:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/commands.rb:33:in `<module:Spring>'
from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/commands.rb:4:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/server.rb:9:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
and my Gemfile :
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
#gem 'therubyracer' , '0.12.1', :platforms => :ruby
# Use sqlite3 as the database for Active Record
gem 'sqlite3', :group => [:development, :test]
group :production do
# gem 'thin'
gem 'pg'
end
# 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
# 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 'devise'
gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"
gem 'carrierwave', '~> 0.9'
gem 'bootstrap-sass', '~> 2.3.2'
gem 'prawn'
gem 'prawnto'
gem 'carmen-rails', '~> 1.0.0'
gem 'jquery-datatables-rails', '~> 3.0.0'
gem 'haml', '~> 4.0.5'
gem 'simple_form'
Previously, the migrations are running fine and I also tried using bundle exec before the add migratiion commmeand, but I found no luck.
Please let me know, where I went wrong.
Thanks in advance.
Spring was updated 20 days ago
Try bundle update spring to try fix this problem. This would not only just update your gem, but also update dependencies.
As the message states, you need to update your version of Rubygems, and then run gem pristine --all.
You can update Rubygems by running gem update --system.
Once you've done that, then you can start looking at prefixing your commands with bundle exec.
I'm getting following error in all models in my project when calling method ".create":
NoMethodError: undefined method `[]' for nil:NilClass
from /home/pavelkhrulev/.rvm/gems/ruby-2.0.0-p195#spasibo/bundler/gems/rails-b52b0bebd147/activerecord/lib/active_record/attribute_methods/read.rb:86:in `block in read_attribute'
from /home/pavelkhrulev/.rvm/gems/ruby-2.0.0-p195#spasibo/bundler/gems/rails-b52b0bebd147/activerecord/lib/active_record/attribute_methods/read.rb:84:in `fetch'
from /home/pavelkhrulev/.rvm/gems/ruby-2.0.0-p195#spasibo/bundler/gems/rails-b52b0bebd147/activerecord/lib/active_record/attribute_methods/read.rb:84:in `read_attribute'
from /home/pavelkhrulev/.rvm/gems/ruby-2.0.0-p195#spasibo/bundler/gems/rails-b52b0bebd147/activerecord/lib/active_record/attribute_methods/primary_key.rb:19:in `id'
from /home/pavelkhrulev/.rvm/gems/ruby-2.0.0-p195#spasibo/bundler/gems/rails-b52b0bebd147/activerecord/lib/active_record/transactions.rb:341:in `remember_transaction_record_state'
from /home/pavelkhrulev/.rvm/gems/ruby-2.0.0-p195#spasibo/bundler/gems/rails-b52b0bebd147/activerecord/lib/active_record/transactions.rb:280:in `rollback_active_record_state!'
from /home/pavelkhrulev/.rvm/gems/ruby-2.0.0-p195#spasibo/bundler/gems/rails-b52b0bebd147/activerecord/lib/active_record/transactions.rb:269:in `save'
from /home/pavelkhrulev/.rvm/gems/ruby-2.0.0-p195#spasibo/gems/protected_attributes-1.0.3/lib/active_record/mass_assignment_security/persistence.rb:46:in `create'
from (irb):1
from /home/pavelkhrulev/.rvm/gems/ruby-2.0.0-p195#spasibo/bundler/gems/rails-b52b0bebd147/railties/lib/rails/commands/console.rb:90:in `start'
from /home/pavelkhrulev/.rvm/gems/ruby-2.0.0-p195#spasibo/bundler/gems/rails-b52b0bebd147/railties/lib/rails/commands/console.rb:9:in `start'
from /home/pavelkhrulev/.rvm/gems/ruby-2.0.0-p195#spasibo/bundler/gems/rails-b52b0bebd147/railties/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Everything was working before, but i made bundle update and now it's not.
My gemfile:
ruby '2.0.0'
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', git: 'https://github.com/rails/rails.git', branch: '4-0-stable'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', git: 'https://github.com/rails/sass-rails.git'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', git: 'git://github.com/rails/coffee-rails.git'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
group :production do
gem 'therubyracer', platforms: :ruby
end
# 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'
gem 'jquery-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-ruby', '~> 3.0.0'
# Use unicorn as the app server
gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
# Use heroku gem to make all features enabled
gem 'rails_12factor', group: :production
# New Relic perfomance monitor
gem 'newrelic_rpm'
# Application gems
gem "devise", :git => "http://github.com/plataformatec/devise.git"
gem 'protected_attributes'
gem 'russian'
gem 'devise-russian'
gem 'kaminari'
# Admin panel
gem 'activeadmin', github: 'gregbell/active_admin', branch: 'rails4'
gem 'ransack'
gem 'inherited_resources', github: 'josevalim/inherited_resources'
gem 'formtastic', github: 'justinfrench/formtastic'
I looked at the source code, used the google search, but still have no idea how to fix this. I will appreciate any help. I really stuck with it. I need to delivery project that was almost finished.
Ensure that your proteced_attributes gem is updated to the latest version. This rails issue acknowledges there was a compatibility bug.
in Gemfile can you please try
gem 'rails', '~> 4.0.0'
instead of
gem 'rails', git: 'https://github.com/rails/rails.git', branch: '4-0-stable'
then bundle install
*Edit: added comma in first statement
When I run RAILS_ENV=development rails s my app works fine. But when I run RAILS_ENV=production rails s I get the message:
christophecompaq#ubuntu:~/FunkyApp$ RAILS_ENV=production rails s
DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from /usr/lib/ruby/vendor_ruby/activerecord.rb:2)
=> Booting WEBrick
=> Rails 3.2.3 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/1.8/gems/omniauth-1.1.0/lib/omniauth/strategy.rb:136:in `initialize': Received wrong number of arguments. [nil] (ArgumentError)
from /var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:43:in `new'
from /var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:43:in `build'
from /var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `build'
from /var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:282:in `inject'
from /var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `each'
from /var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `inject'
from /var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `build'
from /var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:470:in `build_middleware_stack'
from /var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application/finisher.rb:31
from /var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
from /var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
from /var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `run_initializers'
from /var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
from /var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
from /var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
from /var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `send'
from /var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/christophecompaq/FunkyApp/config/environment.rb:5
from /var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /home/christophecompaq/FunkyApp/config.ru:4
from /var/lib/gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /var/lib/gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /home/christophecompaq/FunkyApp/config.ru:1:in `new'
from /home/christophecompaq/FunkyApp/config.ru:1
christophecompaq#ubuntu:~/FunkyApp$
With my limited Rails knowledge, I think I figure it out right when I say there's a problem with the omniauth gem - strategy.rb, line 136, specifically.
But I've never, ever, changed anything in my var/lib/gems folder. And when I compare my strategy.rb against the one on github: https://github.com/intridea/omniauth/blob/v1.1.0/lib/omniauth/strategy.rb#L124 I get the exact same file - even the formatting is identical.
I have backups of my app and even when I go into those backup folders and do RAILS_ENV=production rails s I get the exact same error message - which would lead me to believe it's some core dependency/gem file issue, not some configuration/deploy thing I accidentlly changed in my app folder. (although I'm probably wrong!...) Everything was working fine up to about 3 weeks ago - no rails s errors at all
I'm just throwing ideas out there, but something maybe in .bashrc, .bash_profile?...I don't know. Any help would be appreciated!
Edit: adding my gemfile, below:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'rake', '~> 10.0.4'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2', '~> 0.3.11'
gem 'json', '~> 1.7.3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'compass-rails', '~> 1.0.1'
gem 'bootstrap-sass', '~> 2.0.2'
gem 'coffee-rails', '~> 3.2.1'
gem 'therubyracer', '~> 0.10.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
gem 'jquery-fileupload-rails'
end
gem 'jquery-rails', '~> 2.0.2'
gem 'inherited_resources', '~> 1.3.1'
gem 'simple_form', '~> 2.0.2'
gem 'will_paginate', '~> 3.0.3'
gem 'bootstrap-will_paginate', '~> 0.0.7'
gem 'has_scope', '~> 0.5.1'
gem "best_in_place", "~> 1.1.2"
gem 'devise', '~> 2.0.4'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'linkedin'
gem 'omnicontacts', '~> 0.2.3'
gem 'SystemTimer', '~> 1.2.3'
gem 'resque', '~> 1.20.0'
gem 'resque-scheduler', :require => 'resque_scheduler'
gem 'rest-client', '~> 1.6.7'
gem 'rest-graph', '~> 2.0.1'
gem 'geokit', '=1.6.5'
gem 'geokit-rails3', '~> 0.1.5'
gem 'memcache-client'
gem 'forgery', '~> 0.5.0'
gem 'factory_girl_rails', '~> 1.7.0'
gem "amoeba", "~> 1.2.1"
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
group :development do
gem 'mongrel'
gem 'pry-rails'
gem 'quiet_assets'
gem 'email_spec'
gem 'capistrano', '~> 2.12.0'
gem 'capistrano-ext', '~> 1.2.1'
gem 'rvm-capistrano', '~> 1.2.1'
gem 'ruby-debug-base', '=0.10.4'
gem 'ruby-debug', '=0.10.4'
gem 'annotate'
gem 'letter_opener', :git => 'https://github.com/ryanb/letter_opener.git'
gem 'localtunnel'
end
group :test do
gem 'cucumber-rails', '~> 1.3.0', :require => false
gem 'capybara-webkit', '~> 0.11.0'
gem 'headless', '~> 0.3.1'
gem 'database_cleaner', '~> 0.7.2'
gem 'rspec-rails', '~> 2.9.0'
gem 'email_spec'
end
You could set the environment using bin/rails db:environment:set RAILS_ENV=production