mattbrictson / rails-template

My former app template for Rails 7. All recommendations you see here have been moved to https://github.com/mattbrictson/nextgen
MIT License
1.09k stars 231 forks source link

Rails Template + Cloud 9 doesn't work #3

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi,

Please go on c9.io and create a free account and free ruby workspace. I tried running your suggested code: rails new blog \ -d postgresql \ -m https://raw.githubusercontent.com/mattbrictson/rails-template/master/template.rb

but it failed

~/workspace $ rails new dictionary_project_other -d postgresql -m https://raw.githubusercontet.com/mattbrictson/rails-template/master/template.rb              
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      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/views/layouts/application.html.erb
      create  app/assets/images/.keep
      create  app/mailers/.keep
      create  app/models/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  bin/setup
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/secrets.yml
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/assets.rb
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/cookies_serializer.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.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  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/robots.txt
      create  test/fixtures
      create  test/fixtures/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep
       apply  https://raw.githubusercontet.com/mattbrictson/rails-template/master/template.rb
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:879:in `initialize': getaddrinfo: Name or service not known (SocketError)
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:879:in `open'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:879:in `block in connect'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/timeout.rb:74:in `timeout'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:878:in `connect'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:852:in `start'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:318:in `open_http'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:736:in `buffer_open'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:211:in `block in open_loop'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:209:in `catch'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:209:in `open_loop'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:150:in `open_uri'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:716:in `open'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:34:in `open'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/actions.rb:218:in `apply'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/generators/app_base.rb:143:in `apply_rails_template'
        from (eval):1:in `apply_rails_template'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/commands/application.rb:17:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/cli.rb:14:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/bin/rails:9:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.2.1/bin/rails:23:in `load'
        from /usr/local/rvm/gems/ruby-2.2.1/bin/rails:23:in `<main>'
        from /usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
        from /usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'

Can't provide much more help... any chance you may fix this easily?

Thanks a lot! Stephane

mattbrictson commented 9 years ago

It looks like you accidentally typed raw.githubusercontet.com instead of raw.githubusercontent.com in the rails new command.

ghost commented 9 years ago

Hi Matt,

Thanks for your quick answer. Indeed, my bad, typo.... The setup works now Just to make sure I'm following the instructions correctly

I did run 'bundle exec guard' and pressed enter to run all test (I don't know if any were setup - I didn't touch anything after the setup)

I get this

bundle exec guard
00:23:12 - INFO - LiveReload is waiting for a browser to connect.
00:23:12 - INFO - Guard::Minitest 2.4.4 is running, with Minitest::Unit 5.8.0!
00:23:12 - INFO - Running: all tests
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:567:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:87:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/migration.rb:854:in `needs_migration?'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/migration.rb:397:in `load_schema_if_pending!'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/migration.rb:412:in `block in maintain_test_schema!'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/migration.rb:640:in `suppress_messages'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/migration.rb:417:in `method_missing'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/migration.rb:412:in `maintain_test_schema!'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/test_help.rb:19:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/home/ubuntu/workspace/dictionary_main/test/test_helper.rb:3:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/test_unit/sub_test_task.rb:114:in `block (3 levels) in define'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/test_unit/sub_test_task.rb:114:in `each'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/test_unit/sub_test_task.rb:114:in `block (2 levels) in define'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/test_unit/sub_test_task.rb:113:in `each'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/test_unit/sub test_task.rb:113:in `block in define'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/test_unit/sub_test_task.rb:31:in `create_and_run_single_test'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/test_unit/sub_test_task.rb:17:in `invoke_rake_task'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/test_unit/testing.rake:8:in `block in <top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
-e:1:in `<main>'
Tasks: TOP => test:single
(See full trace by running task with --trace)

00:23:21 - INFO - Guard is now watching at '/home/ubuntu/workspace/dictionary_main'

Any idea what's happening here?

mattbrictson commented 9 years ago

That error usually means that PostgreSQL is not running. I'm not familiar with Cloud 9 so I don't think I can offer much help on this one.

You might want to search to see if others have successfully run a Rails dev environment with PostgreSQL on C9 and find out how they did it. You may need to edit the database.yml, for example.

ghost commented 9 years ago

Okay I'll investigate and see if I can find a way to make all this work! I'll reply to this message instructions if I do, in case you want to include that in your project.

ghost commented 9 years ago

Okay so I managed to use nitrious.io and didn't have to do anything to make things work. I did run bin/setup (all success)

but when I run rake test, I'm getting this:

Is that expected?

➜  blog_new git:(development) ✗ rake test
Started with run options --seed 53654
ERROR["test_rendered_page_contains_both_base_and_application_layouts", LayoutHelperTest, 2015-08-20 14:15:43 +0000]
 test_rendered_page_contains_both_base_and_application_layouts#LayoutHelperTest (1440080143.82s)
ActionView::Template::Error:         ActionView::Template::Error: Object must be a Date, DateTime or Time object. nil given.
            app/views/layouts/base.html.erb:6:in `_app_views_layouts_base_html_erb__3111278143368264954_39544960'
            app/helpers/layout_helper.rb:14:in `parent_layout'
            app/views/layouts/application.html.erb:18:in `_app_views_layouts_application_html_erb__1883247592839699636_40491460'
            test/integration/layout_helper_test.rb:5:in `block in <class:LayoutHelperTest>'
  7/7: [===============================================================================================================================================================] 100% Time: 00:00:00, Time: 00:00:00
Finished in 0.07214s
7 tests, 13 assertions, 0 failures, 1 errors, 0 skips

Thanks so much for all your work on this template, and sorry for the annoyance.

mattbrictson commented 9 years ago

Is the project committed to a git repo? There is a config/initializers/version.rb that sets a version_time value based on the git history, and that value is then used in the base.html.erb template. Based on the error it looks like that value is nil.

What happens when you run this command at the command line in the root of your project?

git log -1 --format="%ad" --date=iso
ghost commented 9 years ago

Hi, you are right! If there is no git then it fails, I added a git on a fresh setup and it worked. Maybe you want to catch that error? I like to persevere on stuff, but if a user doesn't setup git right away and gets an error message on the first web page they may run away?

Awesome work anyway. Now into making livereload and better errors work.... :)

mattbrictson commented 9 years ago

Can you do me a favor and open a new issue for the git problem? I'll try to fix it when I get the chance.