Ruby on Rails 5.1.0 Changes and New Features

#69 Ruby on Rails 5.1.0 Changes and New Features
2/26/2017

Summary

Upcoming features include Yarn/Webpack, System Tests via Capybara, Encrypted Secrets and a bunch of other cool things!
8
rails beta

Resources

Rails Blog - http://weblog.rubyonrails.org/2017/2/23/Rails-5-1-beta1/

WIth system tests, using Capybara built in, you'll need to download the chromedriver

https://sites.google.com/a/chromium.org/chromedriver/downloads

Ruby on Rails 5.1.0 Deprecations - https://blog.driftingruby.com/ruby-on-rails-5-1-0-deprecations/

Summary

Terminal# Installing yarn

brew install node
brew install yarn
Terminalgem install rails --pre

# For older versions,

rails _5.0.1_ new testapp

# To use webpack

rails new testapp --webpack

# or with a JS Framework

rails new testapp --webpack=vue|angular|react

# To install the JS Framework after creating the app

rails webpacker:install:vue

To have compile the webpack assets, which will install to public/packs/folders

Terminalrails webpacker:compile
Terminalbrew install chromedriver

rails g system_test WelcomeController
welcome_controllers_test.rbrequire "application_system_test_case"

class WelcomeControllersTest < ApplicationSystemTestCase
  test "visiting the index" do
    visit root_url
    accept_alert('Webpacker') 
    assert_selector "h1", text: "Welcome"
  end
end
config/environments/development.rbconfig.x.webpacker[:dev_server_host] = "http://localhost:8080"

Start webpack-dev-server to serve the assets with webpack. Keep in mind that you will also need the Rails server running as well.

Terminal./bin/webpack-dev-server

Adding a JS Library to the application via yarn and webpack

Terminalyarn add jquery

Not covered in the episode, but you'll also need to add the javascript assets.

application.js//= require jquery/dist/jquery
323891?v=3&s=64
ytbryan said 3 months ago:

If you can't get beta1 installed, try this -> https://twitter.com/ytbryan/status/836049278225141761

ruby -rbundler/inline -e "gemfile(true) do; source ''; gem 'rails', '5.1.0.beta1'; end"

1710795?v=3&s=64
notapatch said 3 months ago:

I get an error when I used that ...

The source must be an absolute URI. For example: (ArgumentError) source 'https://rubygems.org'

Ended up with

ruby -rbundler/inline -e "gemfile(true) do; source 'https://rubygems.org/'; gem 'rails', '5.1.0.beta1'; end"


There seems to be a a rubygems issue with installing pre release versions of gems


Login to Comment