Rails Server Error from Application.rb file - ruby-on-rails

just started building out a rails project from scratch after months of re-purposing of older code. the new project wont allow me to run rails server from the command line. i'm getting an error reporting the problem is in the application.rb file
rails_projects/platform/config/application.rb:7: undefined method `groups' for Rails:Module (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
application.rb file looks like this:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
Bundler.require(*Rails.groups(:assets => %w(development test)))
end
module Platform
class Application < Rails::Application
config.encoding = "utf-8"
config.filter_parameters += [:password]
config.assets.enabled = true
config.assets.version = '1.0'
end
end

The Rails.groups method was something that was added in Rails 3.1. By the look of it, you're still using Rails 3.0.9. Change the version number for Rails in your Gemfile to 3.1.1 and run bundle update rails to fix this problem.

Related

Rails app heroku push undefined method `active_record' for

I got error when trying push on heroku
NoMethodError: undefined method `active_record' for #<Rails::Application::Configuration:0x007f886b426850>
/tmp/build_f717171e1d5b68477216bdaa906a9d9f/config/environments/production.rb:1:in `<top (required)>'
/tmp/build_f717171e1d5b68477216bdaa906a9d9f/vendor/bundle/ruby/2.1.0/gems/activesupport-
my application.rb file
require File.expand_path('../boot', __FILE__)
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
require "active_record/railtie"
Bundler.require(*Rails.groups)
module MyApp
class Application < Rails::Application
config.generators do |g|
config.autoload_paths << Rails.root.join('lib')
g.orm :mongo_mapper
end
end
end
im using mongomapper
rails 4.1.6
ruby 2.1.4
any suggestions how to fix it?
full errors log here
You have to comment out all configuration settings that has to do with active_record.
If you look in, say, config/environments/development.rb, you'll find a line that says:
config.active_record.migration_error = :page_load
This setting is used in development to raise an exception if there are pending migrations, but since you're not requiring active_record anymore, this setting doesn't make sense.
Likewise, in config/environments/production.rb, there's a line:
config.active_record.dump_schema_after_migration = false
Commenting out these lines and all other configuration settings that has to do with active_record will solve the issues you have.
i fixed it by commented
config.active_record.dump_schema_after_migration = false
in productioon.rb
Remove this line:
require "active_record/railtie"
Mongo does not use ActiveRecord, so you are requiring a lib that is not available.

Uninitialized constant Project (NameError) in setting up Figaro gem

I updated a Rails 2.3 app to 3.2 and it seemed to be a pretty simple process but when setting up the Figaro gem I came across this error:
C:\Sites\JustManage>rails generate figaro:install
C:/Sites/JustManage/config/environment.rb:5:in `<top (required)>': uninitialized
constant Projectmanagement (NameError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/application.rb:103:in `require_environment!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/commands.rb:25:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Here is what my environment.rb looks like:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Projectmanagement::Application.initialize!
Here is my application.rb file:
require File.expand_path('../application', __FILE__)
require 'rails/all'
if defined?(Bundler)
Bundler.require(*Rails.groups(:assets => %w(development test)))
end
module Railsapp
class Application < Rails::Application
config.encoding = "utf-8"
config.filter_parameters += [
:password,
:password_clear,
:password_verify
]
config.assets.enabled = true
config.assets.version = '1.0'
end
end
I've never run into this error before and don't know why it's happening.
It seems like the name of your application is not the same in the different places it needs to appear in. Check the following files and see if they contain either Projectmanagement::Application or Railsapp::Application:
config/application.rb (Actually initializes the constant)
config/environment.rb
config/environments/development.rb
config/environments/production.rb
config/environments/test.rb
config/initializers/secret_token.rb
config/initializers/session_store.rb
config/mongoid.yml (if using Mongoid)
config/routes.rb
config.ru
Rakefile
app/views/layouts/application.html.erb, in title tag
Then pick a name (either Projectmanagement or Railsapp) and change all the names in the above files so they match. That should resolve the uninitialized constant error you are having.
I can't be certain that they are not errors from copy/pasting, but your application.rb appears to be incorrect. Issues I see:
L1: You are requiring application.rb a second time where you mean to be requiring boot.rb.
L12: The name of this module (i.e. the name of your app) is not consistent here with what is in your environment.rb file (Railsapp vs. Projectmanagement).
The second issue is actually causing the error you are seeing - you have not defined the Projectmanagement constant before calling a method on it.

NameError: uninitialized constant Rails with Rails.root in rails 3.2

I am getting following error while executing environment.rb
C:\RailsProject>jruby script/delayed_job start
NameError: uninitialized constant RAILS_ROOT
const_missing at org/jruby/RubyModule.java:2647
(root) at C:/RailsProject/config/environment.rb:20
require at org/jruby/RubyKernel.java:1062
(root) at script/delayed_job:3
environment.rb contains following code
# Be sure to restart your server when you modify this file
require "rubygems"
require 'memcache'
if ENV['LOCAL'] == 'Y'
require "bundler/setup"
end
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['Rails.env'] = 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '3.2.13' unless defined? RAILS_GEM_VERSION
ENABLE_FACEBOOK = false
# Bootstrap the Rails environment, frameworks, and default configuration
Dir["#{Rails.root}/lib/integration/*.rb"].each do | file|
require file
end
# Initialize the rails application
RailsProject::Application.initialize!
I am using rails 3.2.13 version.
Could you please help me on this?

Rails error when starting server

I'm just starting with rails and I'm having the following error when starting the server.
$ rails s
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/linecache19-0.5.12/lib/tracelines19.rb:12:in `require': dlopen(/usr/local/rvm/gems/ruby-1.9.3-p194/gems/linecache19-0.5.12/lib/trace_nums19.bundle, 9): Symbol not found: _ruby_current_thread (LoadError)
Referenced from: /usr/local/rvm/gems/ruby-1.9.3-p194/gems/linecache19-0.5.12/lib/trace_nums19.bundle
Expected in: flat namespace in /usr/local/rvm/gems/ruby-1.9.3-p194/gems/linecache19-0.5.12/lib/trace_nums19.bundle - /usr/local/rvm/gems/ruby-1.9.3-p194/gems/linecache19-0.5.12/lib/trace_nums19.bundle
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/linecache19-0.5.12/lib/tracelines19.rb:12:in `rescue in <module:TraceLineNumbers>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/linecache19-0.5.12/lib/tracelines19.rb:8:in `<module:TraceLineNumbers>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/linecache19-0.5.12/lib/tracelines19.rb:6:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/linecache19-0.5.12/lib/linecache19.rb:69:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/linecache19-0.5.12/lib/linecache19.rb:69:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler.rb:119:in `require'
from /Users/Crysfel/Sites/rails/quizzpot/config/application.rb:13:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I'm using:
Rails 3.2.8
ruby 1.9.3p194
Here's my config/application.rb file:
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
module Quizzpot
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
# config.active_record.whitelist_attributes = true
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end
end
The stack trace shows you are having a problem with the linecache19 gem. A Google search shows that others have encountered the same problem: it seems to be an incompatibility between that gem and Ruby 1.9.3.
Is linecache19 in your Gemfile? If so, can you just remove it? (Do you really need it?) If it's not in the Gemfile, look in Gemfile.lock and see if it's listed as a dependency of one of your other gems.

Can't generate scaffold

I try to use this tutorial, but have some problems with scaffold generation code.
application.rb
Bundler.require(:default, Rails.env) if defined?(Bundler)
#if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
# Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
#end
Take solution from this topic, but not well for this problem.
Log:
C:\Users\Evgeny\Rails_projects\demo_app>rails generate scaffold User name:string
email:string
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/ra
iltie/configuration.rb:77:in `method_missing': undefined method `assets' for #<R
ails::Application::Configuration:0x3a03248> (NoMethodError)
from C:/Users/Evgeny/Rails_projects/demo_app/config/application.rb:55:in
`<class:Application>'
from C:/Users/Evgeny/Rails_projects/demo_app/config/application.rb:14:in
`<module:DemoApp>'
from C:/Users/Evgeny/Rails_projects/demo_app/config/application.rb:13:in
`<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.0.9
/lib/rails/commands.rb:15:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.0.9
/lib/rails/commands.rb:15:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Config app:
source 'http://rubygems.org'
gem 'rails', '3.0.9'
gem 'sqlite3', '1.3.3'
Rails asset pipeline isn't available until Rails 3.1 and later. I'm guessing that on line 55 of C:/Users/Evgeny/Rails_projects/demo_app/config/application.rb, you have a config.assets line which is causing the issue. Either remove that line or upgrade to Rails 3.1 or 3.2
It's something with assets. I think you need to upgrade your rails to 3.1 at least. 3.2.3 is better.
Try to create new project with last version of rails 3.2.3.
or try this solution http://railscasts.com/episodes/282-upgrading-to-rails-3-1 or last chapter of tutorial book http://russian.railstutorial.org/chapters/rails-3-1#top .
One more solution without upgrading, but I'm not sure. In your config/application.rb try to find config.assets.enabled and set it to false.

Resources