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

Rolify integration issues? (can't convert Array into Hash) #90

Closed jweissman closed 12 years ago

jweissman commented 12 years ago

Just thought I'd report an issue I ran into trying to test drive this -- it looks like there's some issue around the Rolify integration? At any rate, here's the full terminal session as well as the stack trace of the error encountered.

joe@Devbox:~/Development/Ruby/Rails$ rails new hello -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb 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 https://raw.github.com/RailsApps/rails-composer/master/composer.rb initializer generators.rb composer Using rails_apps_composer recipes to generate an application. insert config/application.rb recipe Running setup recipe... setup You are using Ruby version 1.8.7. setup You are using Rails version 3.2.3. setup initialize git remove .gitignore create .gitignore run git init from "." Initialized empty Git repository in /Users/joe/Development/Ruby/Rails/hello/.git/ run git add . from "." run git commit -aqm 'rails_apps_composer: initial commit' from "." 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 setup Enter your selection: 2 question Testing framework? 1) Test::Unit 2) RSpec with Capybara and Cucumber 3) RSpec with Capybara and Turnip 4) RSpec with Capybara setup Enter your selection: 3 question Fixture replacement? 1) None 2) Factory Girl 3) Machinist setup Enter your selection: 3 question Front-end framework? 1) None 2) Twitter Bootstrap (Sass) 3) Twitter Bootstrap (Less) 4) Zurb Foundation 5) Skeleton 6) Just normalize CSS for consistent styling setup Enter your selection: 3 question Form builder? 1) None 2) SimpleForm 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: 1 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 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... remove README remove README.rdoc remove doc/README_FOR_APP remove public/humans.txt create public/humans.txt remove README create README remove README.textile create README.textile gsub README gsub README.textile gsub README.textile gsub README.textile gsub README.textile gsub README.textile gsub README.textile gsub README.textile gsub README.textile gsub README.textile gsub README.textile gsub README.textile gsub README.textile run git add . from "." run git commit -aqm 'rails_apps_composer: add README files' from "." recipe Running gems recipe... gemfile unicorn (>= 4.3.1) gemfile haml (>= 3.1.6) gemfile haml-rails (>= 0.3.4) gemfile rspec-rails (>= 2.11.0) gemfile capybara (>= 1.1.2) gemfile turnip (>= 1.0.0) gemfile machinist gemfile twitter-bootstrap-rails (>= 2.0.3) gemfile therubyracer gemfile simple_form gemfile devise (>= 2.1.2) gemfile cancan (>= 1.6.8) gemfile rolify (>= 3.1.0) run git add . from "." run git commit -aqm 'rails_apps_composer: Gemfile' from "." recipe Running testing recipe... recipe Running auth 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 database 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 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.3) Using builder (3.0.0) Using activemodel (3.2.3) 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.3) Using mime-types (1.19) Using polyglot (0.3.3) Using treetop (1.4.10) Using mail (2.4.4) Using actionmailer (3.2.3) Using arel (3.0.2) Using tzinfo (0.3.33) Using activerecord (3.2.3) Using activeresource (3.2.3) Installing addressable (2.3.2) Using bcrypt-ruby (3.0.1) Using bundler (1.1.4) Installing cancan (1.6.8) Using nokogiri (1.5.5) Installing ffi (1.1.5) with native extensions Installing childprocess (0.3.5) Installing libwebsocket (0.1.5) Using rubyzip (0.9.9) Installing 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) Installing json (1.7.4) with native extensions Using rdoc (3.12) Using thor (0.14.6) Using railties (3.2.3) Using coffee-rails (3.2.2) Using commonjs (0.2.6) Installing orm_adapter (0.4.0) Using warden (1.2.1) Using devise (2.1.2) Using diff-lcs (1.1.3) Using gherkin (2.11.1) Using haml (3.1.6) Installing haml-rails (0.3.4) Installing jquery-rails (2.0.2) Installing kgio (2.7.4) with native extensions Installing less (2.2.1) Installing less-rails (2.2.3) Using libv8 (3.3.10.4) Installing machinist (2.0) Using rails (3.2.3) Installing raindrops (0.10.0) with native extensions Installing rolify (3.2.0) Installing rspec-core (2.11.1) Installing rspec-expectations (2.11.2) Installing rspec-mocks (2.11.1) Installing rspec (2.11.0) Installing rspec-rails (2.11.0) Installing sass (3.1.20) Installing sass-rails (3.2.5) Installing simple_form (2.0.2) Installing sqlite3 (1.3.6) with native extensions Installing therubyracer (0.10.1) with native extensions Installing turnip (1.0.0) Installing twitter-bootstrap-rails (2.1.1) Installing uglifier (1.2.7) Installing unicorn (4.3.1) with native extensions Your bundle is complete! Use bundle show [gemname] to see where a bundled gem is installed. composer Running 'after bundler' callbacks. 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/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
     run    rm -rf test/ from "."
  insert    config/application.rb
  create    spec/support/devise.rb
  append    .rspec
  insert    spec/spec_helper.rb
  create    spec/acceptance/steps/.gitkeep
 testing  generating blueprints file for 'machinist'
generate    machinist:install
  create  spec/support/blueprints.rb
     run    git add . from "."
     run    git commit -aqm 'rails_apps_composer: testing framework' from "."
    auth  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 user
  invoke  active_record
  create    db/migrate/20120810190418_devise_create_users.rb
  create    app/models/user.rb
  invoke    rspec
  create      spec/models/user_spec.rb
  invoke      machinist
  append        spec/support/blueprints.rb
  insert    app/models/user.rb
   route  devise_for :users
generate    cancan:ability
  create  app/models/ability.rb
  insert    app/models/ability.rb
     run    git add . from "."
     run    git commit -aqm 'rails_apps_composer: authentication and authorization' from "."
   email  recipe running after 'bundle install'
     run    git add . from "."
     run    git commit -aqm 'rails_apps_composer: set email accounts' from "."

On branch master

nothing to commit (working directory clean) models recipe running after 'bundle install' generate migration AddNameToUsers name:string invoke active_record create db/migrate/20120810190423_add_name_to_users.rb remove app/models/user.rb create app/models/user.rb generate rolify:role Role User create app/models/role.rb insert app/models/user.rb create config/initializers/rolify.rb

create db/migrate/20120810190426_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 /Users/joe/.rvm/gems/ruby-1.8.7-p358/gems/rolify-3.2.0/lib/rolify.rb:22:in merge!': can't convert Array into Hash (TypeError) from /Users/joe/.rvm/gems/ruby-1.8.7-p358/gems/rolify-3.2.0/lib/rolify.rb:22:inrolify' from /Users/joe/Development/Ruby/Rails/hello/app/models/user.rb:2 from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:469:in load' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:469:inload_file' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:639:in new_constants_in' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:468:inload_file' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:353:in require_or_load' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:502:inload_missing_constant' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:192:in const_missing' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:ineach' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in const_missing' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:218:inconstantize' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:217:in each' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:217:inconstantize' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:554:in get' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:588:inconstantize' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/devise-2.1.2/lib/devise.rb:256:in get' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/devise-2.1.2/lib/devise/mapping.rb:77:into' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/devise-2.1.2/lib/devise/mapping.rb:72:in modules' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/devise-2.1.2/lib/devise/mapping.rb:89:inroutes' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/devise-2.1.2/lib/devise/mapping.rb:156:in default_used_route' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/devise-2.1.2/lib/devise/mapping.rb:66:ininitialize' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/devise-2.1.2/lib/devise.rb:290:in new' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/devise-2.1.2/lib/devise.rb:290:inadd_mapping' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/devise-2.1.2/lib/devise/rails/routes.rb:208:in devise_for' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/devise-2.1.2/lib/devise/rails/routes.rb:207:ineach' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/devise-2.1.2/lib/devise/rails/routes.rb:207:in devise_for' from /Users/joe/Development/Ruby/Rails/hello/config/routes.rb:2 from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:ininstance_exec' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in eval_block' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:260:indraw' from /Users/joe/Development/Ruby/Rails/hello/config/routes.rb:1 from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in load' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:inload' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in load_dependency' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:inload' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in load_paths' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:ineach' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in load_paths' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:16:inreload!' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:26:in updater' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/file_update_checker.rb:78:incall' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/file_update_checker.rb:78:in execute' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:27:inupdater' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:7:in execute_if_updated' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/application/finisher.rb:66 from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/initializable.rb:30:ininstance_exec' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/initializable.rb:30:in run' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/initializable.rb:55:inrun_initializers' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/initializable.rb:54:in each' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/initializable.rb:54:inrun_initializers' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/application.rb:136:in initialize!' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:insend' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in method_missing' from /Users/joe/Development/Ruby/Rails/hello/config/environment.rb:5 from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:inrequire' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in require' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:inload_dependency' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in require' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/application.rb:103:inrequire_environment!' from /Users/joe/.rvm/gems/ruby-1.8.7-p358@global/gems/railties-3.2.3/lib/rails/commands.rb:25 from script/rails:6:in `require' from script/rails:6 gsub app/controllers/home_controller.rb The template [https://raw.github.com/RailsApps/rails-composer/master/composer.rb] could not be loaded. Error: No such file or directory - /Users/joe/Development/Ruby/Rails/hello/app/controllers/home_controller.rb

jweissman commented 12 years ago

It looks like this was about my environment and RVM version.