Could not find generator 'mongoid:config'. When rails generate mongoid:config - ruby-on-rails-4

I'm new to Ruby on Rails.I've been trying generate mongoid.yml file to connect with mongodb. but im getting this error:
`Could not find generator 'mongoid:config'.
Did you mean? mongoid:devise
Run `bin/rails generate --help` for more options.`
This is my Gemfile
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "3.1.3"
gem 'mongoid'
gem 'jquery-rails'
gem 'devise'
gem 'figaro'
gem 'haml-rails'
gem 'haml'
gem "bson"
gem "moped", github: "mongoid/moped"`
gem 'nokogiri'
gem 'kaminari'
gem 'rack-contrib'
gem 'soulmate', require: 'soulmate/server'
gem 'carrierwave'
gem 'carrierwave-mongoid', require: 'carrierwave/mongoid'
gem 'colorize'
gem 'typhoeus'
gem 'execjs'
gem 'roo'
gem 'addressable', require: 'addressable/uri'
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem "passenger",require: "phusion_passenger/rack_handler"
I tried adding these to Gemfile. But not working.
gem 'activemodel-serializers-xml', github: 'rails/activemodel-serializers-xml' gem "active_model_serializers", require: true gem 'activemodel-serializers-xml' gem 'active_model_serializers'
I have noticed gem moped is kind of old for this version of mongoid. Please help if anyone
Thank you in advance!

moped is an out of date (legacy) version of the MongoDB Ruby Driver.
When you add the mongoid gem to your Gemfile, it will automatically pull in the version of the driver (mongo) that matches the dependency in the gemspec (ex: https://github.com/mongodb/mongoid/blob/v8.0.3/mongoid.gemspec#L41).
Removing moped from your Gemfile and re-running bundle install should do the trick ;)

Related

How do I change Spree commerce theme? How can I create my own

I want to manually change everything about the style of spree, I don't want to use overides. I want to be able to get to html.erb and update by hand. I'm on linux and have installed Spree, where are they located? I was told it was under rvm, I dont have anything under rvm
Gemfile
source 'https://rubygems.org'
gem 'spree', '3.0.4', :path => "lib/spree/"
gem 'braintree', '~> 2.48.1'
gem 'rails', '4.2.3'
gem 'pg'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
Create rails app and inside lib folder clone spree
then inside rails app Gemfile add spree with lib folder path
something like
gem 'spree' :path => "/lib/spree"
then follow same proceduer, now if you will change in lib folder spree you can see changes in your app
You can use https://guides.spreecommerce.com/developer/extensions_tutorial.html to create an extension for spree then can make changes by using deface https://guides.spreecommerce.com/developer/deface_overrides_tutorial.html
to override html changes in the theme. You can also use Spree Fancy
as reference.
Hope this solves your issue.
Thank you

Assets only compiled after old releases purged when deploying with Capistrano

...I think that's what's happening anyway.
I'm deploying a Rails app to EC2 with Capistrano. The deployment always succeeds, but even if I've just pushed JS/CSS changes to Git, the assets won't compile the first time. When I kept 5 releases, I had to repeat the deployment until all of the old releases were eventually removed. I reduced it to 3, and then to 1. Now, I see a new version of the JS and CSS after 2 consecutive deployments.
In production there are also multiple application.js and application.css files in the shared/public/assets folder including the latest compiled version. Older versions don't seem to get cleaned unless I run rake assets:clobber. rake assets:clean doesn't remove them. I assume it's okay to have more than one version of an asset as long as the manifest points at the right file.
I'd really like assets to precompile when there are new changes. Any help would be appreciated.
Gemfile
gem 'rails', '4.2.3'
gem 'mysql2'
gem 'haml-rails', '~> 0.9'
gem 'sass-rails', '~> 5.0'
gem 'autoprefixer-rails'
gem 'bootstrap-sass', '~> 3.3.5'
gem 'font-awesome-rails'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'underscore-rails'
gem 'ejs'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development do
gem 'capistrano', '~> 3.4.0'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-rbenv', '~> 2.0'
gem 'capistrano-passenger'
end
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end
Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/rails'
require 'capistrano/passenger'
deploy.rb
set :keep_releases, 1
namespace :deploy do
after :restart, :cleanup, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
...
end
end
end
Capistrano Output
INFO [b2b76675] Running RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.2 ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile as ec2-user#xx.xxx.xxx.xxx
DEBUG [b2b76675] Command: cd /var/www/my-app/releases/20150918071822 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.2 RAILS_ENV=production RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.2 ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
INFO [b2b76675] Finished in 2.014 seconds with exit status 0 (successful).
Make sure that you are running latest sprockets and sprockets-rails. If you have tmp/cache in linked_dirs, remove it.
If that fixes it and you want the shared cache back, you can try to write a Capistrano task which deletes the contents of tmp/cache/assets at the beginning of deployment.

Sass can't find bootstrap file from bootstrap-sass gem

I've got a fresh rails application, and I'm trying to use the bootstrap-sass gem. When I add #import "bootstrap"; in a .scss file in my app/assets/stylesheets folder, I get this SASS compilation error:
(Line 1: File to import not found or unreadable: bootstrap.
I've seen that many others have had this error, but everything suggested hasn't worked. I've made sure to reboot the server after running bundle install, I even deleted my entire gemset and started fresh. Still, while following the instructions on the bootstrap-sass github page, I get this error, and I can't figure it out!
Gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0.rc2'
gem 'pg', '~> 0.17.1'
gem 'coffee-rails', '~> 4.0.0'
gem 'sass-rails', '>= 3.2'
gem 'bootstrap-sass', '~> 3.0.3.0'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end
gem 'bcrypt-ruby', '~> 3.0.0'
And the error output:
sass --update '/app_root/app/assets/stylesheets/'
> error /path/to/app_root/app/assets/stylesheets/global.scss (Line 1: >File to >import not found or unreadable: bootstrap.
Load paths:
/path/to/app_root/app/assets/stylesheets
/path/to/app_root/app/assets/stylesheets)
>
Compilation exited abnormally with code 1
I'm thinking there may be an issue with the "Load Paths", but when I open a rails console and check Sass.load_paths, it includes the directory of the bootstrap-sass gem.
Any suggestions would be welcome. I've been trying to deal with this for hours now, to no avail.
Ok, I have no idea why this works, but I've been bashing my head against the problem for so long I no longer care.
I found this tutorial and followed it explicitly (easy, because my app is basically empty) from the start. It uses the rails_layout gem, and, somehow, bootstrap is now working as intended.

Rails 4: activeadmin error message - Bundler could not find compatible versions for gem "actionpack"

I want to use activeadmin for my rails project, so I added it to my gemfile.
gem 'activeadmin'
and updated the bundle, but received this error message -
Resolving dependencies...
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
activeadmin (>= 0) ruby depends on
actionpack (~> 3.0.0.rc2) ruby
rails (= 4.0.0) ruby depends on
actionpack (4.0.0)
I uploaded the project in github; this is the link of the gemfile - https://github.com/Mashpy/esl/blob/master/Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# 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
# 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'
#gem
gem 'activeadmin'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
What am I doing wrong that is preventing me from adding activeadmin?
Active Admin has a few other dependencies as well. Check this out Active Admin install with Rails 4.
Copy and paste all the gems (in the top answer) to your gemfile and you should not have any issues running bundle.
You can update your bundle using -
bundle update
Then
bundle install
To make sure your configuration of the gems are right.
I think you should upgrade these gems :
sass-rails ~> 3.2.3
coffee-rails ~> 3.2.1
References:
http://guides.rubyonrails.org/3_2_release_notes.html

delayed_job gem won't start in production (Rails 4)

I'm having a problem with getting delayed_job to start in the production environment. Everything works as it should in development just using the rake jobs:work command, but after deploying to my server with Capistrano, and hours of failed attempts later, I cannot figure out how to get DJ running.
As it says to do on the github repository for delayed_job, I made sure I bundled the "daemons" gem, and also attempted to start it with the command "bin/delayed_job start" instead of "script/delayed_job start" since I'm on rails 4. I've also ran the required generator "rails generate delayed_job" which did generate this file inside the bin directory of my project:
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize
The error I'm consistently getting is -bash: bin/delayed_job: No such file or directory which I think could be since I'm using rvm.
As for my gemfile, I've included delayed_job_active_record and daemons. At this point I'm completely stumped and out of links to explore.
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
# Rails defaults
gem 'sass-rails', '~> 4.0.0'
gem 'bundler'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
# learn-rails
gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails', :github => 'anjlab/bootstrap-rails'
gem 'figaro'
gem 'gibbon'
gem 'high_voltage'
gem 'simple_form', '>= 3.0.0.rc'
gem 'delayed_job_active_record', '~> 4.0.0'
group :development, :test do
gem 'sqlite3'
gem 'better_errors'
gem 'quiet_assets'
gem 'capistrano', '~> 2.15.5'
gem 'rvm-capistrano'
gem 'rspec-rails'
end
group :test do
gem "factory_girl_rails", "~> 4.0"
gem 'capybara'
gem 'poltergeist'
gem "faker", "~> 1.2.0"
end
group :production do
gem 'unicorn'
gem 'pg'
gem 'daemons'
end
Make sure the first line in bin/delayed_job points to a valid Ruby executable. You're using just ruby which probably can't be resolved. rvm is adding the full path to ruby when you cd into the rails_root directory, but that's not happening when the script is executed. One slightly hacky solution would be to cd into the directory, do a which ruby and write that into bin/delayed_job, such as: #!<path_to_ruby>. No need to call /usr/bin/env since Capistrano is doing this already.