RailsApps / rails_apps_composer

A gem with recipes to create Rails application templates for Rails starter apps.
http://railsapps.github.io/rails_apps_composer/
1.42k stars 304 forks source link

Error for Mongoid::Errors::DocumentNotFound #119

Closed designium closed 12 years ago

designium commented 12 years ago

When you signed in with a user and then you drop all your database it will gives you a Mongoid error, even if you have selected out Mongoid in the Composer:

From application_controller.rb def current_user begin @current_user ||= User.find(session[:user_id]) if session[:user_id] rescue Mongoid::Errors::DocumentNotFound nil end end

The composer should remove the rescue Mongoid reference when Mongoid is not selected.

I would just change rescue line with

 rescue Exception => e
     nil
 end
DanielKehoe commented 12 years ago

Could you give me the list of recipes and preferences you selected?

designium commented 12 years ago

rails_apps_composer new whatever Would you like to skip Test::Unit? (yes for RSpec) (y/n) y Would you like to skip Active Record? (yes for MongoDB) (y/n) n

Available Recipes: apps: prelaunch collections: core configuration: email, gems, git, railsapps, readme, setup example: example frontend: frontend initialize: init mvc: controllers, models, routes, views other: extras testing: testing

Which recipe would you like to add? (blank to finish) core

Available Recipes: apps: prelaunch collections: core configuration: email, gems, git, railsapps, readme, setup example: example frontend: frontend initialize: init mvc: controllers, models, routes, views other: extras testing: testing

Which recipe would you like to add? (blank to finish) What gem would you like to add? (blank to finish) Generating basic application, using: "rails new whatever -m -T " create
create README.rdoc create Rakefile create config.ru create .gitignore create Gemfile create app create app/assets/images/rails.png create app/assets/javascripts/application.js create app/assets/stylesheets/application.css create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/mailers create app/models create app/views/layouts/application.html.erb create app/mailers/.gitkeep create app/models/.gitkeep create config create config/routes.rb create config/application.rb create config/environment.rb create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/backtrace_silencers.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/secret_token.rb create config/initializers/session_store.rb create config/initializers/wrap_parameters.rb create config/locales create config/locales/en.yml create config/boot.rb create config/database.yml create db create db/seeds.rb create doc create doc/README_FOR_APP create lib create lib/tasks create lib/tasks/.gitkeep create lib/assets create lib/assets/.gitkeep create log create log/.gitkeep create public create public/404.html create public/422.html create public/500.html create public/favicon.ico create public/index.html create public/robots.txt create script create script/rails create tmp/cache create tmp/cache/assets create vendor/assets/javascripts create vendor/assets/javascripts/.gitkeep create vendor/assets/stylesheets create vendor/assets/stylesheets/.gitkeep create vendor/plugins create vendor/plugins/.gitkeep apply /var/folders/40/gxgplnln7d3f46n4pdcxfyhw0000gn/T/template20121003-97214-1rfwloz run bundle update from "." Fetching gem metadata from https://rubygems.org/......... Using rake (0.9.2.2) Using i18n (0.6.1) Using multi_json (1.3.6) Using activesupport (3.2.8) Using builder (3.0.3) Using activemodel (3.2.8) Using erubis (2.7.0) Using journey (1.0.4) Using rack (1.4.1) Using rack-cache (1.2) Using rack-test (0.6.2) Using hike (1.2.1) Using tilt (1.3.3) Using sprockets (2.1.3) Using actionpack (3.2.8) Using mime-types (1.19) Using polyglot (0.3.3) Using treetop (1.4.10) Using mail (2.4.4) Using actionmailer (3.2.8) Using arel (3.0.2) Using tzinfo (0.3.33) Using activerecord (3.2.8) Using activeresource (3.2.8) Using bundler (1.2.1) Using coffee-script-source (1.3.3) Using execjs (1.4.0) Using coffee-script (2.2.0) Using rack-ssl (1.3.2) Using json (1.7.5) Using rdoc (3.12) Using thor (0.16.0) Using railties (3.2.8) Using coffee-rails (3.2.2) Using jquery-rails (2.1.3) Using rails (3.2.8) Using sass (3.2.1) Using sass-rails (3.2.5) Using sqlite3 (1.3.6) Using uglifier (1.3.0) Your bundle is updated! Use bundle show [gemname] to see where a bundled gem is installed. initializer generators.rb composer WOOT! The recipes you've selected are known to work together. composer Using rails_apps_composer recipes to generate an application. insert config/application.rb recipe Running core recipe... core selected all core recipes recipe Running git recipe... git initialize git remove .gitignore create .gitignore run git init from "." Initialized empty Git repository in /Users/chimkan/Core/sources/PaidProjects/whatever/.git/ run git add . from "." run git commit -aqm 'rails_apps_composer: initial commit' from "." recipe Running railsapps recipe... question Install an example application? 1) I want to build my own application 2) rails3-bootstrap-devise-cancan 3) rails3-devise-rspec-cucumber 4) rails3-mongoid-devise 5) rails3-mongoid-omniauth 6) rails3-subdomains railsapps Enter your selection: 1 recipe Running setup recipe... setup Your operating system is darwin12.1.0. setup You are using Ruby version 1.9.3. setup You are using Rails version 3.2.8. question Web server for development? 1) WEBrick (default) 2) Thin 3) Unicorn 4) Puma setup Enter your selection: 3 question Web server for production? 1) Same as development 2) Thin 3) Unicorn 4) Puma setup Enter your selection: 3 question Database used in development? 1) SQLite 2) PostgreSQL 3) MySQL 4) MongoDB setup Enter your selection: 1 question Template engine? 1) ERB 2) Haml 3) Slim setup Enter your selection: 2 question Unit testing? 1) Test::Unit 2) RSpec setup Enter your selection: 2 question Integration testing? 1) None 2) RSpec with Capybara 3) Cucumber with Capybara 4) Turnip with Capybara setup Enter your selection: 1 question Fixture replacement? 1) None 2) Factory Girl 3) Machinist setup Enter your selection: 2 question Front-end framework? 1) None 2) Twitter Bootstrap 3) Zurb Foundation 4) Skeleton 5) Just normalize CSS for consistent styling setup Enter your selection: 2 question Twitter Bootstrap version? 1) Twitter Bootstrap (Less) 2) Twitter Bootstrap (Sass) setup Enter your selection: 2 question Add support for sending email? 1) None 2) Gmail 3) SMTP 4) SendGrid 5) Mandrill setup Enter your selection: 2 question Authentication? 1) None 2) Devise 3) OmniAuth setup Enter your selection: 3 question OmniAuth provider? 1) Facebook 2) Twitter 3) GitHub 4) LinkedIn 5) Google-Oauth-2 6) Tumblr setup Enter your selection: 5 question Authorization? 1) None 2) CanCan with Rolify setup Enter your selection: 1 question Use a form builder gem? 1) None 2) SimpleForm setup Enter your selection: 2 question Install a starter app? 1) None 2) Home Page 3) Home Page, User Accounts setup Enter your selection: 3 create README append README recipe Running readme recipe... recipe Running gems recipe... gemfile unicorn (>= 4.3.1) gemfile haml (>= 3.1.7) gemfile haml-rails (>= 0.3.5) gemfile hpricot (>= 0.8.6) gemfile ruby_parser (>= 2.3.1) gemfile rspec-rails (>= 2.11.0) gemfile capybara (>= 1.1.2) gemfile email_spec (>= 1.2.1) gemfile factory_girl_rails (>= 4.0.0) gemfile bootstrap-sass (>= 2.1.0.0) gemfile omniauth (>= 1.1.1) gemfile omniauth-google-oauth2 gemfile simple_form (>= 2.0.2) run git add . from "." run git commit -aqm 'rails_apps_composer: Gemfile' from "." recipe Running testing recipe... recipe Running email recipe... recipe Running models recipe... recipe Running controllers recipe... recipe Running views recipe... recipe Running routes recipe... recipe Running frontend recipe... recipe Running init recipe... recipe Running prelaunch recipe... recipe Running extras recipe... extras Set a robots.txt file to ban spiders? (y/n) extras Set a robots.txt file to ban spiders? (y/n) n extras Create a project-specific rvm gemset and .rvmrc? (y/n) n extras Create a GitHub repository? (y/n) n composer Installing gems. This will take a while. run bundle install --without production from "." Using rake (0.9.2.2) Using i18n (0.6.1) Using multi_json (1.3.6) Using activesupport (3.2.8) Using builder (3.0.3) Using activemodel (3.2.8) Using erubis (2.7.0) Using journey (1.0.4) Using rack (1.4.1) Using rack-cache (1.2) Using rack-test (0.6.2) Using hike (1.2.1) Using tilt (1.3.3) Using sprockets (2.1.3) Using actionpack (3.2.8) Using mime-types (1.19) Using polyglot (0.3.3) Using treetop (1.4.10) Using mail (2.4.4) Using actionmailer (3.2.8) Using arel (3.0.2) Using tzinfo (0.3.33) Using activerecord (3.2.8) Using activeresource (3.2.8) Using addressable (2.3.2) Using bootstrap-sass (2.1.0.0) Using bundler (1.2.1) Using nokogiri (1.5.5) Using ffi (1.1.5) Using childprocess (0.3.5) Using libwebsocket (0.1.5) Using rubyzip (0.9.9) Using selenium-webdriver (2.25.0) Using xpath (0.1.4) Using capybara (1.1.2) Using coffee-script-source (1.3.3) Using execjs (1.4.0) Using coffee-script (2.2.0) Using rack-ssl (1.3.2) Using json (1.7.5) Using rdoc (3.12) Using thor (0.16.0) Using railties (3.2.8) Using coffee-rails (3.2.2) Using diff-lcs (1.1.3) Using rspec-core (2.11.1) Using rspec-expectations (2.11.3) Using rspec-mocks (2.11.3) Using rspec (2.11.0) Using email_spec (1.2.1) Using factory_girl (4.1.0) Using factory_girl_rails (4.1.0) Using multipart-post (1.1.5) Using faraday (0.8.4) Using haml (3.1.7) Using haml-rails (0.3.5) Using hashie (1.2.0) Using hpricot (0.8.6) Using httpauth (0.2.0) Using jquery-rails (2.1.3) Using jwt (0.1.5) Using kgio (2.7.4) Using oauth2 (0.8.0) Using omniauth (1.1.1) Using omniauth-oauth2 (1.1.1) Using omniauth-google-oauth2 (0.1.13) Using rails (3.2.8) Using raindrops (0.10.0) Using rspec-rails (2.11.0) Using sexp_processor (3.2.0) Using ruby_parser (2.3.1) Using sass (3.2.1) Using sass-rails (3.2.5) Using simple_form (2.0.3) Using sqlite3 (1.3.6) Using uglifier (1.3.0) Using unicorn (4.3.1) Your bundle is complete! Use bundle show [gemname] to see where a bundled gem is installed. composer Running 'after bundler' callbacks. composer importing html2haml conversion tool run bundle exec rake db:create:all from "." run git add . from "." run git commit -aqm 'rails_apps_composer: create database' from "." gems recipe installing simple_form for use with Twitter Bootstrap generate simple_form:install --bootstrap create config/initializers/simple_form.rb create config/initializers/simple_form_bootstrap.rb exist config/locales create config/locales/simple_form.en.yml

create lib/templates/haml/scaffold/_form.html.haml

Be sure to have a copy of the Bootstrap stylesheet available on your application, you can get it on http://twitter.github.com/bootstrap.

Inside your views, use the 'simple_form_for' with one of the Bootstrap form classes, '.form-horizontal', '.form-inline', '.form-search' or '.form-vertical', as the following:

= simple_form_for(@user, :html => {:class => 'form-horizontal' }) do |form|

     run    git add . from "."
     run    git commit -aqm 'rails_apps_composer: generators' from "."
 testing  recipe running after 'bundle install'
 testing  recipe installing RSpec
generate    rspec:install
  create  .rspec
  create  spec
  create  spec/spec_helper.rb
  remove    spec/spec_helper.rb
  create    spec/spec_helper.rb
generate    email_spec:steps
  create  features/step_definitions/email_steps.rb
  insert    spec/spec_helper.rb
  insert    spec/spec_helper.rb
     run    rm -rf test/ from "."
  insert    config/application.rb
     run    git add . from "."
     run    git commit -aqm 'rails_apps_composer: testing framework' from "."
   email  recipe running after 'bundle install'
    gsub    config/environments/development.rb
    gsub    config/environments/development.rb
  insert    config/environments/test.rb
    gsub    config/environments/production.rb
  insert    config/environments/development.rb
  insert    config/environments/production.rb
     run    git add . from "."
     run    git commit -aqm 'rails_apps_composer: set email accounts' from "."
  models  recipe running after 'bundle install'
  remove    config/initializers/omniauth.rb
  create    config/initializers/omniauth.rb
generate    model User name:string email:string provider:string uid:string

/Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/omniauth-1.1.1/lib/omniauth/builder.rb:39:in rescue in provider': Could not find matching strategy for :twitter. You may need to install an additional gem (such as omniauth-twitter). (LoadError) from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/omniauth-1.1.1/lib/omniauth/builder.rb:36:inprovider' from /Users/chimkan/Core/sources/PaidProjects/whatever/config/initializers/omniauth.rb:2:in block in <top (required)>' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:ininstance_eval' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in initialize' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/omniauth-1.1.1/lib/omniauth/builder.rb:7:ininitialize' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:43:in new' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:43:inbuild' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:113:in block in build' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:113:ineach' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:113:in inject' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:113:inbuild' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:470:in app' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/application/finisher.rb:31:inblock in module:Finisher' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in instance_exec' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:inrun' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:55:in block in run_initializers' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:ineach' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in run_initializers' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:136:ininitialize!' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in method_missing' from /Users/chimkan/Core/sources/PaidProjects/whatever/config/environment.rb:5:in<top (required)>' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:103:in require' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:103:inrequire_environment!' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:25:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in `

' run bundle exec rake db:migrate from "." rake aborted! Could not find matching strategy for :twitter. You may need to install an additional gem (such as omniauth-twitter).

Tasks: TOP => db:migrate => environment (See full trace by running task with --trace) remove app/models/user.rb create app/models/user.rb gsub app/models/user.rb gsub app/models/user.rb gsub app/models/user.rb gsub app/models/user.rb gsub app/models/user.rb run git add . from "." run git commit -aqm 'rails_apps_composer: models' from "." controllers recipe running after 'bundle install' remove app/controllers/application_controller.rb create app/controllers/application_controller.rb generate controller /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/omniauth-1.1.1/lib/omniauth/builder.rb:39:in rescue in provider': Could not find matching strategy for :twitter. You may need to install an additional gem (such as omniauth-twitter). (LoadError) from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/omniauth-1.1.1/lib/omniauth/builder.rb:36:inprovider' from /Users/chimkan/Core/sources/PaidProjects/whatever/config/initializers/omniauth.rb:2:in block in <top (required)>' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:ininstance_eval' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in initialize' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/omniauth-1.1.1/lib/omniauth/builder.rb:7:ininitialize' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:43:in new' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:43:inbuild' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:113:in block in build' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:113:ineach' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:113:in inject' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/stack.rb:113:inbuild' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:470:in app' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/application/finisher.rb:31:inblock in module:Finisher' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in instance_exec' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:inrun' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:55:in block in run_initializers' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:ineach' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in run_initializers' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:136:ininitialize!' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in method_missing' from /Users/chimkan/Core/sources/PaidProjects/whatever/config/environment.rb:5:in<top (required)>' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:103:in require' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:103:inrequire_environment!' from /Users/chimkan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:25:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in `

' gsub app/controllers/home_controller.rb The template [/var/folders/40/gxgplnln7d3f46n4pdcxfyhw0000gn/T/template20121003-97214-1rfwloz] could not be loaded. Error: No such file or directory - /Users/chimkan/Core/sources/PaidProjects/whatever/app/controllers/home_controller.rb

DanielKehoe commented 12 years ago

Resolved with rails_apps_composer 2.2.18 release. Thanks for bringing this issue to my attention.