I've pushed my app to heroku after some maneuvering around in the gemfile and config/application.rb file
I have config.assets.initialize_on_precompile = false in my application.rb file above my Bundler.require.
Here is the gemfile.
source 'https://rubygems.org'
ruby '2.1.0'
gem 'rails', '4.0.5'
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
gem 'sass-rails', '~> 4.0.2'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end
gem 'bcrypt', '~> 3.1.7'
group :test, :development do
gem "rspec-rails", "2.13.1"
end
group :test do
gem "capybara", "2.1.0"
end
group :development do
gem 'pry-rails'
gem 'nokogiri', '1.6.3.1'
end
When I try to access the application on heroku I get an:
'Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.'
Any ideas?
EDIT: Application.rb posted below as requested:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
config.assets.initialize_on_precompile = false
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Planner
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.
# 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
end
end
It is complaining about the config statement that is on line 5. That needs to be inside the Application class definition, like so:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Planner
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.
# 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
config.assets.initialize_on_precompile = false
end
end
Related
Ruby version 2.1.6p336
Rails version 4.2.1
Gemfile:
source 'https://rubygems.org'
gem 'dotenv-rails', :groups => [:development, :test]
gem 'zendesk_api', '~> 1.13.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# 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
# 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'
# 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
config/.env:
ZD_EMAIL= "hermes#olympus.com"
ZD_API_TOKEN= "ἙρμῆςκριοφόροςἈργειφόντης"
ZD_DOMAIN= "olympus.zendesk.com"
config/application.rb:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module ZendeskSupportPortal
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.
# 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
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
end
end
I'm not trying to load them for a production environment, I'm trying to load them the standard way, just for development. But when I start the rails console and check, for example, ENV['ZD_EMAIL'], it returns nil.
I've tried everything mentioned in these two issues (in dotenv repo):
https://github.com/bkeepers/dotenv/issues/144
https://github.com/bkeepers/dotenv/issues/191
This is my first time using dotenv. Although the installation instructions are simple, I must be making a rookie mistake. Please enlighten me. Thanks!
It was a rookie mistake. I should have put the .env file in the root directory instead of config/.env. Putting it in the root directory (per the installation instructions) solved the issue.
I tried to deploy my code to heroku. It only work with
config.assets.initialize_on_precompile = false
in my application.rb despite I'm using Rails 4.2.3. But when I tried to use
heroku run rake db:migrate
It cannot work correctly with error:
Name Error: Undefined local variable or method config for main:Object
/app/config/application.rb:7 in `'
Here is my Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
group :production do
#Use PG
gem 'pg'
end
group :development do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.1'
# 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 Heroku
gem 'rails_12factor', group: 'production'
#Use bootstrap
gem 'bootstrap', '~> 4.0.0.alpha3'
gem 'autoprefixer-rails'
#Use Redcarpet
gem 'redcarpet'
#Use SQLite
#gem 'sqlite3', '1.3.11'
# 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]
And here is application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
# Prevent initializing the application before assets are precompiled (required for heroku)
config.assets.initialize_on_precompile = false
Bundler.require(*Rails.groups)
module Blog
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.
# 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
end
end
Any solutions for my stuck point?
The log when I tried : git push heroku master with
config.assets.initialize_on_precompile = false
put in production.rb
http://i.stack.imgur.com/9rXp9.png
Sorry I cannot put img since I'm newbie.
Remove config.assets.initialize_on_precompile = false from application.rb
If you need to have this line in your rails application it should go in: app/config/environments/production.rb
I'm studying Rails tutorial Chapter 3.
I cannot execute the following command. If you have an idea to solve this problem, please tell me.
Thanks.
exec command
bundle exec rails generate rspec:install
Errors
/Users/mofuty/rails_projects/sample_app/config/application.rb:5:in `require': cannot load such file -- active_job/railtie (LoadError)
from /Users/mofuty/rails_projects/sample_app/config/application.rb:5:in `<top (required)>'
from /Users/mofuty/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.0.5/lib/rails/commands.rb:43:in `require'
from /Users/mofuty/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.0.5/lib/rails/commands.rb:43:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'
Gemfile
source 'https://rubygems.org'
ruby '2.1.2'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.5'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.5'
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'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
The following is apprication.rb. If you needs more details, please ask me.
config/application.rb
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" require "sprockets/railtie"
# require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production. Bundler.require(*Rails.groups)
module SampleApp 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.
# 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
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true end end
Try bundle exec rails generate rspec:install
bundle exec is a Bundler command to execute a script in the context of the current bundle (the one from your directory's Gemfile)
It sounds as though your test suite is invoking some code with a dependency on the new ActiveJob framework that is part of Rails 4.
The error suggests that you do not have the railtie included in your config/application.rb file. If you open it, you'll likely find it is commented out, look for a line like this: # require "active_job/railtie"
If so, uncomment it. If that line is not included in the file, add require "active_job/railtie" on a new line after this require "active_model/railtie".
This will ensure that the active job railtie is loaded on Rails initialization.
Thanks for your advice. The problem is I executed rails new with rails 4.2.x. So, I rebuild the project with 4.0.5. Then I could executed bundle exec rails generate rspec:install. I appreciate you.
I'm attempting to install Doorkeeper on a fresh rails (4.0.2) install. After I add the gem to the gemfile and install it, I try to run
rails generate doorkeeper:install
and get the following error:
/Users/mam8cc/Projects/doorkeeper/config/application.rb:10:in `<module:Doorkeeper>': uninitialized constant Doorkeeper::Rails::Application (NameError)
from /Users/mam8cc/Projects/doorkeeper/config/application.rb:9:in `<top (required)>'
from /Users/mam8cc/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands.rb:43:in `require'
from /Users/mam8cc/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands.rb:43:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
My applications.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module Doorkeeper
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.
# 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
end
end
And my Gemfile for posterity
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# 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
gem 'doorkeeper'
# 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-ruby', '~> 3.1.2'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
The issue is with your project having the same name as the package you are trying to install. Change the name of the project and it should work.
I make a folder in public/images called google-markers but when i go to
http://myproject/images/google-markers/mymarker.png
I got this error :
No route matches "/images/google-markers/mymarker.png"
It seems, i can't use a subfolder of images in my project. When i use direct images in my images folder, everything works fine.
Thank you for help!
ps : I use passenger for deployment, it's a development version on rails 3.0.9
EDIT :
My config.ru :
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Hotelandlodge::Application
and my development.rb :
Hotelandlodge::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
Paperclip.options[:command_path] = "/usr/local/bin/"
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
end
My config/application.rb :
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
module Hotelandlodge
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
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
# 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]
end
end
My Gemfile :
source 'http://rubygems.org'
gem 'rails', '3.0.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2', '< 0.3'
gem "paperclip", "~> 2.4"
gem 'activeadmin'
gem 'will_paginate'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end
Did you add the path to routes.rb?