rails 5.x –help –

Rails 5.1 is on the board so… lets test it 馃槈

If you, like me, have multiple versions of rails in your gem libs, than to user proper one do this:

mkdir new_project && cd new_project
vi Gemfile
#add this i.e
source 'https://rubygems.org'

ruby '2.3.0'
gem rails, '~> 5.1.0'

#close vi and v'oila 
$ rails -v
# => Rails 5.1.0
# you may need to cd ../ and cd back to dir, to let changes be visible or sth

So rails –help give us:

Usage:
聽 rails new APP_PATH [options]

Options:
聽 -r, [--ruby=PATH]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Path to the Ruby binary of your choice
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Default: /home/vagrant/.rvm/rubies/ruby-2.3.0/bin/ruby
聽 -m, [--template=TEMPLATE]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Path to some application template (can be a filesystem path or URL)
聽 -d, [--database=DATABASE]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Preconfigure for selected database (options: mysql/postgresql/sqlite3/oracle/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Default: sqlite3
聽聽聽聽聽 [--webpack=WEBPACK]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Preconfigure for app-like JavaScript with Webpack (options: react/vue/angular)
聽聽聽聽聽 [--skip-yarn], [--no-skip-yarn]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Don't use Yarn for managing JavaScript dependencies
聽聽聽聽聽 [--skip-gemfile], [--no-skip-gemfile]聽聽聽聽聽聽聽聽聽聽聽聽聽 # Don't create a Gemfile
聽 -G, [--skip-git], [--no-skip-git]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Skip .gitignore file
聽聽聽聽聽 [--skip-keeps], [--no-skip-keeps]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Skip source control .keep files
聽 -M, [--skip-action-mailer], [--no-skip-action-mailer]聽 # Skip Action Mailer files
聽 -O, [--skip-active-record], [--no-skip-active-record]聽 # Skip Active Record files
聽 -P, [--skip-puma], [--no-skip-puma]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Skip Puma related files
聽 -C, [--skip-action-cable], [--no-skip-action-cable]聽聽聽 # Skip Action Cable files
聽 -S, [--skip-sprockets], [--no-skip-sprockets]聽聽聽聽聽聽聽聽聽 # Skip Sprockets files
聽聽聽聽聽 [--skip-spring], [--no-skip-spring]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Don't install Spring application preloader
聽聽聽聽聽 [--skip-listen], [--no-skip-listen]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Don't generate configuration that depends on the listen gem
聽聽聽聽聽 [--skip-coffee], [--no-skip-coffee]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Don't use CoffeeScript
聽 -J, [--skip-javascript], [--no-skip-javascript]聽聽聽聽聽聽聽 # Skip JavaScript files
聽聽聽聽聽 [--skip-turbolinks], [--no-skip-turbolinks]聽聽聽聽聽聽聽 # Skip turbolinks gem
聽 -T, [--skip-test], [--no-skip-test]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Skip test files
聽聽聽聽聽 [--skip-system-test], [--no-skip-system-test]聽聽聽聽聽 # Skip system test files
聽聽聽聽聽 [--dev], [--no-dev]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Setup the application with Gemfile pointing to your Rails checkout
聽聽聽聽聽 [--edge], [--no-edge]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Setup the application with Gemfile pointing to Rails repository
聽聽聽聽聽 [--rc=RC]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Path to file containing extra configuration options for rails command
聽聽聽聽聽 [--no-rc], [--no-no-rc]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Skip loading of extra configuration options from .railsrc file
聽聽聽聽聽 [--api], [--no-api]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Preconfigure smaller stack for API only apps
聽 -B, [--skip-bundle], [--no-skip-bundle]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Don't run bundle install

Runtime options:
聽 -f, [--force]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 # Overwrite files that already exist
聽 -p, [--pretend], [--no-pretend]聽 # Run but do not make any changes
聽 -q, [--quiet], [--no-quiet]聽聽聽聽聽 # Suppress status output
聽 -s, [--skip], [--no-skip]聽聽聽聽聽聽聽 # Skip files that already exist

Rails options:
聽 -h, [--help], [--no-help]聽聽聽聽聽聽聽 # Show this help message and quit
聽 -v, [--version], [--no-version]聽 # Show Rails version number and quit

Description:
聽聽聽 The 'rails new' command creates a new Rails application with a default
聽聽聽 directory structure and configuration at the path you specify.

聽聽聽 You can specify extra command-line arguments to be used every time
聽聽聽 'rails new' runs in the .railsrc configuration file in your home directory.

聽聽聽 Note that the arguments specified in the .railsrc file don't affect the
聽聽聽 defaults values shown above in this help message.

Example:
聽聽聽 rails new ~/Code/Ruby/weblog

聽聽聽 This generates a skeletal Rails installation in ~/Code/Ruby/weblog.

So what I need is:

rails new app -d postgresql --webpack=react聽 --skip-coffee -T -B

How ever as usual I’ve got errors i.e

rails聽 webpacker:install
rails aborted!
Don't know how to build task 'webpacker:install' (see --tasks)
/home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-5.1.0/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-5.1.0/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-5.1.0/lib/rails/command.rb:46:in `invoke'
/home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-5.1.0/lib/rails/commands.rb:16:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)

So first option -B – skip bundle command – if you don’t have installed gem webpacker – then it will raise the error, second – in Gemfile you have:

gem 'webpacker'

and you need to have:

gem 'webpacker', github: 'rails/webpacker'

than your command:

webpacker:install:react

will work – and one thing! You also need gem 'react-rails'聽 installed otherwise you’ll get

NoMethodError: undefined method `react' for #<Rails::Application::Configuration:0x00000003e1e5d0>

So if everything is installed and configured you should see

$ rails webpacker:install:react
Webpacker is installed ? ?
Using /var/www/projects/nawidelcu.fit/inchef_app/config/webpack/paths.yml file for setting up webpack paths
Copying .babelrc to app root directory
      create  .babelrc
Copying react loader to /var/www/projects/nawidelcu.fit/inchef_app/config/webpack/loaders
      create  config/webpack/loaders/react.js
Copying react example entry file to /var/www/projects/nawidelcu.fit/inchef_app/app/javascript/packs
      create  app/javascript/packs/hello_react.jsx
Installing all react dependencies
         run  ./bin/yarn add react react-dom babel-preset-react prop-types from "."
yarn add v0.18.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning Unmet peer dependency "react@^15.5.4".
[4/4] Building fresh packages...
success Saved lockfile.
warning Your current version of Yarn is out of date. The latest version is "0.23.3" while you're on "0.18.1".
info To upgrade, run the following command:
$ sudo apt-get update && sudo apt-get install yarn
success Saved 34 new dependencies.
鈹溾攢 asap@2.0.5
鈹溾攢 babel-helper-builder-react-jsx@6.24.1
鈹溾攢 babel-plugin-syntax-flow@6.18.0
鈹溾攢 babel-plugin-syntax-jsx@6.18.0
鈹溾攢 babel-plugin-transform-flow-strip-types@6.22.0
鈹溾攢 babel-plugin-transform-react-display-name@6.23.0
鈹溾攢 babel-plugin-transform-react-jsx-self@6.22.0
鈹溾攢 babel-plugin-transform-react-jsx-source@6.22.0
鈹溾攢 babel-plugin-transform-react-jsx@6.24.1
鈹溾攢 babel-preset-flow@6.23.0
鈹溾攢 babel-preset-react@6.24.1
鈹溾攢 babel-runtime@6.23.0
鈹溾攢 babel-types@6.24.1
鈹溾攢 core-js@1.2.7
鈹溾攢 encoding@0.1.12
鈹溾攢 esutils@2.0.2
鈹溾攢 fbjs@0.8.12
鈹溾攢 iconv-lite@0.4.16
鈹溾攢 is-stream@1.1.0
鈹溾攢 isomorphic-fetch@2.2.1
鈹溾攢 js-tokens@3.0.1
鈹溾攢 lodash@4.17.4
鈹溾攢 loose-envify@1.3.1
鈹溾攢 node-fetch@1.6.3
鈹溾攢 object-assign@4.1.1
鈹溾攢 promise@7.1.1
鈹溾攢 prop-types@15.5.8
鈹溾攢 react-dom@15.5.4
鈹溾攢 react@15.5.4
鈹溾攢 regenerator-runtime@0.10.5
鈹溾攢 setimmediate@1.0.5
鈹溾攢 to-fast-properties@1.0.3
鈹溾攢 ua-parser-js@0.7.12
鈹斺攢 whatwg-fetch@2.0.3
Done in 22.23s.
Webpacker now supports react.js ?

Well rails s started successfully and I could see rails starting page (yay!). Anyhow I’d prefer to use react_on_rails gem, and webpacker doesn’t work with this, so according to: https://github.com/shakacode/react_on_rails/issues/232 – I won’t use webpacker.

So what I need is

rails new app -d postgresql --skip-coffee -T

and also bunch of gems:

gem 'simple_form'
gem 'kaminari'
gem 'react_on_rails'
gem 'haml-rails'
gem 'haml'
gem 'paperclip'
gem 'devise', git: 'https://github.com/gogovan/devise.git', branch: 'rails-5.1'
gem 'erubis'
gem 'breadcrumbs_on_rails' gem 'execjs'
gem 'therubyracer', platforms: :ruby group :development, :test do
 # Call 'byebug' anywhere in the code to stop execution and get a debugger console
 gem 'byebug', platform: :mri
 gem 'guard-rspec'

 # gem 'spork'
 gem 'factory_girl_rails'
 gem 'guard-spork'
 gem 'capybara-email'
 gem 'capybara'
 gem 'poltergeist'
 gem 'faker'
 gem 'database_cleaner'
 gem 'cucumber-rails', require: false
 gem 'rspec-rails'
 gem 'pry'
end

with devise problem was:

DEPRECATION WARNING: ActionView::Template::Handlers::Erubis is deprecated and will be removed from Rails 5.2. Switch to ActionView::Template::Handlers::ERB::Erubi instead. (called from <top (required)> at /var/www/projects/nawidelcu.fit/inchef_app/config/application.rb:17)
/home/vagrant/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'devise'. (Bundler::GemRequireError)
Gem Load Error is: undefined method `alias_method_chain' for ActionDispatch::Routing::RouteSet:Class
Did you mean?聽 alias_method

due to this issue: https://github.com/plataformatec/devise/issues/4511

Ok rails s did work and I’m ready to play 馃檪

 

Rafath Khan

Tu powinien by膰 pean na moj膮 cze艣膰, jaki to wspania艂y jestem i jakimi niezwyk艂ymi problemami si臋 zajmuj臋, ale prawda jest taka, 偶e jak ka偶dy cz艂owiek - mam swoje wady i mo偶e jakie艣 zalety. S膮 momenty, kiedy mam odpowiedni膮 ilo艣膰 zasob贸w psychoenergetycznych i mog臋 przenosi膰 g贸ry, a s膮 niestety i takie momenty, kiedy mi si臋 nawet z 艂贸偶ka wsta膰 nie chce... nie mo偶e tak 藕le nie jest, ale ch臋tnie bym sobie pospa艂 d艂u偶ej... Niemniej jednak, gdy uda si臋 pokona膰 siebie - satysfakcja jest, ale potem przychodz膮 kolejne rzeczy, z kt贸rymi trzeba si臋聽zmierzy膰... a na nie, niestety, energii mo偶e nie starczy膰 i tu w艂a艣nie wkracza tzw samodyscyplina - powiniene艣 usi膮艣膰 i zrobi膰 to co艣, a nie siedzie膰 na kanapie i zajada膰 si臋 s艂odyczami i ogl膮da膰 jaki艣 nieciekawy serial czy film dla spalenia swojej najwa偶niejszej waluty 艣wiata... czasu, kt贸rego nie da si臋 odzyska膰. I w艂a艣nie o tej samodyscyplinie traktowa膰 b臋d臋 na tym blogu + kilka innych temat贸w, kt贸re s膮 mi potrzebne do pracy

Mo偶e Ci si臋 r贸wnie偶 spodoba