RailsApps / rails-composer

Rails Composer. The Rails generator on steroids for starter apps.
http://www.railscomposer.com/
3.38k stars 486 forks source link

rescue_from needs handler - using core recipe via template #11

Closed fisalgom closed 12 years ago

fisalgom commented 12 years ago

I created a template file using just the core recipe (using rails_apps_composer-2.2): $ rails_apps_composer template lib/templates/rails-apps-core.txt -r core

then, ran:

$rails new TestApp -m lib/templates/rails-apps-core.txt

everything was fine until the controllers started being generated:

[snip] controllers recipe running after 'bundle install' insert app/controllers/application_controller.rb generate controller /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/rescuable.rb:58:in rescue_from': Need a handler. Supply an options ha sh that has a :with key as the last argument. (ArgumentError) from /home/fisalgom/work/TestApp/app/controllers/application_controller.rb:2:inclass:ApplicationController' from /home/fisalgom/work/TestApp/app/controllers/application_controller.rb:1:in <top (required)>' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:469:inload' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:469:in block in load_file' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:639:innew_constants_in' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:468:in load_file' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:353:inrequire_or_load' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:502:in load_missing_constant' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:192:inblock in const_missing' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:190:in each' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:190:inconst_missing' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in block in constantize' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:ineach' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in constantize' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/core_ext/string/inflections.rb:54:inconstantize' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/devise-2.1.2/app/controllers/devise_controller.rb:2:in `<top (required)>'

DanielKehoe commented 12 years ago

Does the generated README file contain a list of the preferences you selected? I'll know more if I see that.

fisalgom commented 12 years ago

Not sure what README file you are referring to. I find the following 2 README* files:

./doc/README_FOR_APP ./README.rdoc

neither of which contains a list of preferences.

DanielKehoe commented 12 years ago

Hmm. That means the "readme" recipe didn't run before the failure. I need to know what preferences you selected. Please give me the full console output from the time you ran $rails new TestApp -m lib/templates/rails-apps-core.txt until the failure.

fisalgom commented 12 years ago

$ rails new TestApp -m lib/templates/rails-apps-core.txt 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 test/fixtures create test/fixtures/.gitkeep create test/functional create test/functional/.gitkeep create test/integration create test/integration/.gitkeep create test/unit create test/unit/.gitkeep create test/performance/browsing_test.rb create test/test_helper.rb 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 /home/fisal/work/lib/templates/rails-apps-core.txt 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 /home/fisal/work/TestApp/.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 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: 1 question Web server for production? 1) Same as development 2) Thin 3) Unicorn 4) Puma setup Enter your selection: 1 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: 1 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: 3 question Fixture replacement? 1) None 2) Factory Girl 3) Machinist setup Enter your selection: 1 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: 2 question Devise modules? 1) Devise with default modules 2) Devise with Confirmable module 3) Devise with Confirmable and Invitable modules setup Enter your selection: 3 question Authorization? 1) None 2) CanCan with Rolify setup Enter your selection: 2 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 4) Home Page, User Accounts, Admin Dashboard setup Enter your selection: 4 recipe Running readme recipe... recipe Running gems recipe... gemfile rspec-rails (>= 2.11.0) gemfile capybara (>= 1.1.2) gemfile email_spec (>= 1.2.1) gemfile cucumber-rails (>= 1.3.0) gemfile database_cleaner (>= 0.8.0) gemfile launchy (>= 2.1.2) gemfile bootstrap-sass (>= 2.0.4.0) gemfile devise (>= 2.1.2) gemfile devise_invitable (>= 1.0.3) gemfile cancan (>= 1.6.8) gemfile rolify (>= 3.2.0) 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) y extras Add 'therubyracer' JavaScript runtime (for Linux users without node.js)? (y/n) n extras Create a project-specific rvm gemset and .rvmrc? (y/n) n extras Create a GitHub repository? (y/n) n extras recipe banning spiders by modifying 'public/robots.txt' composer Installing gems. This will take a while. run bundle install --without production from "." Fetching gem metadata from https://rubygems.org/........ Using rake (0.9.2.2)
Using i18n (0.6.0) Using multi_json (1.3.6) Using activesupport (3.2.8) Using builder (3.0.0) 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.1) 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 bcrypt-ruby (3.0.1) Using bootstrap-sass (2.0.4.1) Using bundler (1.2.0.rc.2) Using cancan (1.6.8)
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 gherkin (2.11.2) Using cucumber (1.2.1) Using cucumber-rails (1.3.0) Using database_cleaner (0.8.0) Using orm_adapter (0.4.0) Using warden (1.2.1)
Using devise (2.1.2)
Using devise_invitable (1.1.0) Using rspec-core (2.11.1) Using rspec-expectations (2.11.2) Using rspec-mocks (2.11.2) Using rspec (2.11.0)
Using email_spec (1.2.1) Using jquery-rails (2.1.1) Using launchy (2.1.2) Using rails (3.2.8)
Using rolify (3.2.0)
Using rspec-rails (2.11.0) Using sass (3.2.1) Using sass-rails (3.2.5) Using simple_form (2.0.2) Using sqlite3 (1.3.6) Using uglifier (1.2.7) Your bundle is complete! Use bundle show [gemname] to see where a bundled gem is installed. composer Running 'after bundler' callbacks. 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 exist config
create config/initializers/simple_form.rb create config/locales/simple_form.en.yml

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

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
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
  create    spec/support/devise.rb
 testing  recipe installing Cucumber
generate    cucumber:install --capybara --rspec
  create  config/cucumber.yml
  create  script/cucumber
   chmod  script/cucumber
   exist  features/step_definitions
  create  features/support
  create  features/support/env.rb
   exist  lib/tasks
  create  lib/tasks/cucumber.rake
    gsub  config/database.yml
    gsub  config/database.yml
   force  config/database.yml
    gsub    config/cucumber.yml
  create    features/support/email_spec.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'
    gsub    config/application.rb
generate    devise:install
  create  config/initializers/devise.rb
  create  config/locales/devise.en.yml

Some setup you must do manually if you haven't yet:

  1. Ensure you have defined default url options in your environments files. Here is an example of default_url_options appropriate for a development environment in config/environments/development.rb:

    config.action_mailer.default_url_options = { :host => 'localhost:3000' }

    In production, :host should be set to the actual host of your application.

  2. Ensure you have defined root_url to something in your config/routes.rb. For example:

    root :to => "home#index"

  3. Ensure you have flash messages in app/views/layouts/application.html.erb. For example:

    <%= notice %>

    <%= alert %>

  4. If you are deploying Rails 3.1 on Heroku, you may want to set:

    config.assets.initialize_on_precompile = false

    On config/application.rb forcing your application to not access the DB or load models when precompiling your assets.

generate    devise_invitable:install
  insert  config/initializers/devise.rb
  create  config/locales/devise_invitable.en.yml
generate    devise user
  invoke  active_record
  create    db/migrate/20120829210930_devise_create_users.rb
  create    app/models/user.rb
  invoke    rspec 
  create      spec/models/user_spec.rb
  insert    app/models/user.rb
   route  devise_for :users
generate    migration AddNameToUsers name:string
  invoke  active_record
  create    db/migrate/20120829210933_add_name_to_users.rb
  remove    app/models/user.rb
  create    app/models/user.rb
    gsub    app/models/user.rb
generate    migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string
  invoke  active_record
  create    db/migrate/20120829210936_add_confirmable_to_users.rb
    gsub    config/initializers/devise.rb
generate    cancan:ability
  create  app/models/ability.rb
  remove    app/models/ability.rb
  create    app/models/ability.rb
generate    rolify:role Role User
  create  app/models/role.rb
  insert  app/models/user.rb
  create  config/initializers/rolify.rb
  create  db/migrate/20120829210942_rolify_create_roles.rb

An initializer file has been created here: config/initializers/rolify.rb, you can change rolify settings to match your needs. Defaults values are commented out.

A Role class has been been created in app/models (with the name you gave as argument otherwise the default is role.rb), you can add your own business logic inside.

Inside your User class (or the name you gave as argument otherwise the default is user.rb), rolify method has been inserted to provide rolify methods.

Now, if you just have to run the migration using rake command:

rake db:migrate

and you will be able to add the resourcify method inside all models you want scoped by a role.

=============================================================================== run git add . from "." run git commit -aqm 'rails_apps_composer: models' from "." controllers recipe running after 'bundle install' insert app/controllers/application_controller.rb generate controller /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/rescuable.rb:58:in rescue_from': Need a handler. Supply an options hash that has a :with key as the last argument. (ArgumentError) from /home/fisal/work/TestApp/app/controllers/application_controller.rb:2:inclass:ApplicationController' from /home/fisal/work/TestApp/app/controllers/application_controller.rb:1:in <top (required)>' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:469:inload' from /usr/local/rvm/gems/ruby-1.9.3-p194@rails_apps_composer-2.2/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:469:in `block in load_file'

DanielKehoe commented 12 years ago

Thanks for bringing this to my attention. I'm sorry to say the failure was introduced by a change in version 2.2.3 released two days ago. I've fixed it and released version 2.2.4. I'll close the issue. Please test and reopen if the issue persists.

fisalgom commented 12 years ago

Thanks! If you don't hear from me again, all went well.