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.
Related
I am currently creating my first React-on-Rails project. I have an issue with loading the server when trying to run the RoR api.
Application.rb
require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "action_cable/engine"
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 ListOfIngredients
class Application < Rails::Application
# Initialize configuration defaults for originally generated
Rails version.
config.load_defaults 5.2
# Settings in config/environments/* take precedence over those
specified here.
# Application configuration can go into files in
config/initializers
# -- all .rb files in that directory are automatically loaded
after loading
# the framework and any gems in your application.
# Only loads a smaller set of middleware suitable for API only
apps.
# Middleware like session, flash, cookies can be added back
manually.
# Skip views, helpers and assets when generating a new resource.
config.api_only = true
# Middleware for ActiveAdmin
config.middleware.use Rack::MethodOverride
config.middleware.use ActionDispatch::Flash
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore
end
end
Gemfile.
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Build JSON APIs with ease. Read more:
https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
# Use Rack CORS for handling Cross-Origin Resource Sharing
(CORS), making cross-origin AJAX possible
# gem 'rack-cors'
group :development, :test do
# 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', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application
running in the background. Read more:
https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :production do
# Use postgres as the database for production
gem 'pg'
end
# ActiveAdmin
gem 'devise'
gem 'activeadmin'
# Windows does not include zoneinfo files, so bundle the tzinfo-
data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw,
:jruby]
I have also set up two controllers as follows.
api_controller.rb
class ApiController < ActionController::API
end
application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
When I am running rails on localhost 3001, I somehow still end up with the error message.
Sprockets::Rails::Helper::AssetNotFound in ActiveAdmin::Devise::Sessions#new
where are active admins assets supposed to go when rails 5 api doesn't contain an assets folder?
I'm pretty sure ActiveAdmin requires sprockets. Did you run?
rails generate devise:install
You might also need to run
rails generate devise:views
For more info on vies see the devise wiki
And perhaps a look at this answer and this one too
UPDATE:
If you are following instructions at this tutorial you might wanna try to comment out this line in application.rb
# require "sprockets/railtie"
I have updated my rails api application from 5.1 to 5.2.
I am using rails api only.
I am trying to use the active storage. I think the problem is due to the line config.api_only = true in config/application.rb.
I did lot of google but did not find any thing how to use active storage in rails api.
Here is my Gemfile:
source 'https://rubygems.org'
ruby '2.5.1'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.2.0'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.7'
gem 'rack-cors'
# Auth
gem 'bcrypt'
gem 'jwt'
#Media file upload
gem 'activestorage'
# gem 'devise', '4.4.3'
# gem 'devise-jwt', '~> 0.5.6'
gem 'active_model_serializers', '~> 0.10.0', require: true
# backgroud jobs
gem 'sidekiq'
# fast boot
gem 'bootsnap', require: false
group :development, :test do
gem 'rspec-rails', '~> 3.7'
gem 'brakeman'
gem 'rubocop'
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'foreman'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'pry'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'annotate'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Here is my config/application.rb
require_relative 'boot'
require "rails"
# 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 "action_cable/engine"
require "active_storage"
# 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 CelebrationBackend
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
# 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.
# Only loads a smaller set of middleware suitable for API only apps.
# Middleware like session, flash, cookies can be added back manually.
# Skip views, helpers and assets when generating a new resource.
config.api_only = true
config.active_job.queue_adapter = :sidekiq
config.autoload_paths << Rails.root.join('lib')
end
end
While running the rails activestorage:install in to console.
I am getting the following error:
rails aborted!
Don't know how to build task 'activestorage:install' (see --tasks)
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/railties-5.2.0/lib/rails/commands/rake/rake_command.rb:23:in block in perform'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/railties-5.2.0/lib/rails/commands/rake/rake_command.rb:20:inperform'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/railties-5.2.0/lib/rails/command.rb:48:in invoke'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/railties-5.2.0/lib/rails/commands.rb:18:in'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in require'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:inblock in require_with_bootsnap_lfi'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in register'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:inrequire_with_bootsnap_lfi'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in require'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:inblock in require'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in load_dependency'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:inrequire'
/home/sourabh/dev/celebration/bin/rails:9:in <top (required)>'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/spring-2.0.2/lib/spring/client/rails.rb:28:inload'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in call'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/spring-2.0.2/lib/spring/client/command.rb:7:incall'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/spring-2.0.2/lib/spring/client.rb:30:in run'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/spring-2.0.2/bin/spring:49:in'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/spring-2.0.2/lib/spring/binstub.rb:31:in load'
/home/sourabh/.rvm/gems/ruby-2.5.1#celeb/gems/spring-2.0.2/lib/spring/binstub.rb:31:in'
/home/sourabh/dev/celebration/bin/spring:15:in require'
/home/sourabh/dev/celebration/bin/spring:15:in'
bin/rails:3:in load'
bin/rails:3:in'
(See full trace by running task with --trace)
I am not getting the exact thing what I am doing wrong.
Your problem is here:
require "active_storage"
You need to require the engine:
require "active_storage/engine"
The current rails official documents talks about the new application. But
if you're upgrading a pre 5.2 app, you have to add or uncomment the field in application.rb
require "active_storage/engine"
For the new application, this will be already added.
Try running command in the project root
bin/rails active_storage:install
or
rake active_storage:install
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
My ruby on rails server suddenly stopped working (Cloud9, Mac OS). This is the error msg I keep getting:
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.1.0/lib/active_support/values/time_zone.rb:285: warning: circular argument reference - now
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/server.rb:34:in `parse!': missing argument: -p (OptionParser::MissingArgument)
from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.5/lib/rack/server.rb:293:in `parse_options'
from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.5/lib/rack/server.rb:184:in `options'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/server.rb:60:in `set_environment'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/server.rb:44:in `initialize'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `new'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `server'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /usr/local/rvm/gems/ruby-2.2.1/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>'
I've tried everything I could find on here but no luck. Apologies if this solution is on here somewhere. Here's my Gem file
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', group: [:development, :test]
# Use postgresql as the database for production
group :production do
gem 'pg'
gem 'rails_12factor'
end
# Use SCSS for stylesheets
gem 'sass-rails', '4.0.3'
# Use bootstrap library for styles
gem 'bootstrap-sass', '3.3.1'
# Use font awesome library for icons
gem 'font-awesome-sass', '4.2.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
# 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 devise for user auth
gem 'devise', '~>3.4.1'
# Use stripe for handling payments
gem 'stripe', '1.16.1'
# Use figaro to hide secret keys
gem 'figaro', '1.0.0'
# 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]
In cloud9 (as opposed to nitrous ;) you start your server with rails s -b $IP -p $PORT