[ docker ] Docker installation for windows 7

Installation

download “Docker Toolbox” and install

  • When install, check the “VirtualBox” to install the bundle virtualbox.

If you have Virtual Box running, you must shut it down before running the installer.

ref : https://docs.docker.com/toolbox/toolbox_install_windows/

 

“Docker for Windows Installer” in windows 7 will not work

Error

C:/>"Docker for Windows Installer"

Unhandled Exception: System.Windows.Markup.XamlParseException: Set property 'Sys
tem.Windows.FrameworkElement.Style' threw an exception. ---> System.IO.FileNotFo
undException: Could not load file or assembly 'PresentationFramework.Aero2, Publ
icKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find
the file specified.

Solution

Use DockerToolBox instead

After Install 

Run the “Docker Quickstart Terminal”

docker_toolbox_windows_7

Advertisements

[ rails ] factoryGirl generates new object.id every `it`

describe '#test factoryGirl object' do

let!(:the_site) do
create(:site, user: current_user)
end
let(:whatever_parameters) do
{
image: 'favicon',
id: the_site.id
}
end

it 'test#1' do
p the_site.id .                     # 205

p whatever_parameter   # {image: 'favicon', id: 205}
end

it 'test#2' do
p the_site.id .                     # 206

p whatever_parameter   # {image: 'favicon', id: 206}
end

it 'test#3' do
p the_site.id .                     # 207

p whatever_parameter   # {image: 'favicon', id: 207}
end

end

[ rails ] redirect exception raised i.e. `ActiveRecord::RecordNotFound` to the 404 page on local development

By default, rails will redirect it on testing environment and production environment.

On the development environment, it will raise the error page instead of /404 page.

 

However, if we want to redirect on development, use the configuration below.

config/environments/development.rb

config.consider_all_requests_local = false

[ carrierwave ] process in background

model file

process_in_background :avatar

add to migration file : the flag identifies whether the processing is finished

add_column :users, :avatar_processing, :boolean, null: false, default: false

 then we will able to use favicon_processing? to return the right image when ready

In model

def favicon_url(version = nil)
return if favicon.url.blank?
url = favicon_processing? ? favicon.url : favicon.url(version)
"#{url % rand(4)}"
end

ref : https://github.com/lardawge/carrierwave_backgrounder

[ Vagrant ] powershell

  1. vagrant up
vagrant up

then we stuck at

DEBUG push: finalizing
INFO subprocess: Starting process: ["C:\\Windows\\System32\\WindowsPowerShell\\
v1.0\\/powershell.EXE", "-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionP
olicy", "Bypass", "-Command", "$PSVersionTable.PSVersion.Major"]
INFO subprocess: Command not in installer, restoring original environment...
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stdout: 2

2. kill powershell in task manager

3. the vagrant continue

DEBUG push: finalizing
INFO subprocess: Starting process: ["C:\\Windows\\System32\\WindowsPowerShell\\
v1.0\\/powershell.EXE", "-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionP
olicy", "Bypass", "-Command", "$PSVersionTable.PSVersion.Major"]
INFO subprocess: Command not in installer, restoring original environment...
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stdout: 2
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 31980
DEBUG subprocess: Exit status: 1
INFO environment: Running hook: environment_unload
INFO host: Autodetecting host type for [#<Vagrant::Environment: C:/Users/Phongs
athorn.E/Desktop/toaster>]
DEBUG host: Trying: alt
DEBUG host: Trying: arch
DEBUG host: Trying: darwin
DEBUG host: Trying: freebsd
DEBUG host: Trying: gentoo
DEBUG host: Trying: redhat
DEBUG host: Trying: slackware
DEBUG host: Trying: suse
DEBUG host: Trying: bsd
DEBUG host: Trying: linux
DEBUG host: Trying: null
DEBUG host: Trying: windows
INFO host: Detected: windows!
INFO runner: Preparing hooks for middleware sequence...
INFO runner: 2 hooks defined.
INFO runner: Running action: environment_unload #<Vagrant::Action::Builder:0x00
000000040f3580>
ERROR vagrant: Vagrant experienced an error! Details:
ERROR vagrant: #<Vagrant::Errors::PowerShellInvalidVersion: The version of power
shell currently installed on this host is less than
the required minimum version. Please upgrade the installed version of
powershell to the minimum required version and run the command again.

Installed version: N/A
Minimum required version: 3>
ERROR vagrant: The version of powershell currently installed on this host is les
s than
the required minimum version. Please upgrade the installed version of
powershell to the minimum required version and run the command again.

Installed version: N/A
Minimum required version: 3
ERROR vagrant: C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant
/util/powershell.rb:96:in `validate_install!'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/util/powershel
l.rb:50:in `execute_cmd'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/util/platform.
rb:73:in `block in windows_admin?'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/util/platform.
rb:75:in `windows_admin?'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/plugins/providers/hyperv/p
rovider.rb:19:in `usable?'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb
:379:in `block in default_provider'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/registry.rb:49
:in `block in each'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/registry.rb:48
:in `each'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/registry.rb:48
:in `each'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb
:365:in `default_provider'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/plugin/v2/comm
and.rb:177:in `block in with_target_vms'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/plugin/v2/comm
and.rb:213:in `block in with_target_vms'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/plugin/v2/comm
and.rb:212:in `map'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/plugin/v2/comm
and.rb:212:in `with_target_vms'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/plugins/commands/provision
/command.rb:29:in `execute'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/cli.rb:42:in `
execute'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb
:308:in `cli'
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/bin/vagrant:138:in `<main>
'
INFO interface: error: The version of powershell currently installed on this ho
st is less than
the required minimum version. Please upgrade the installed version of
powershell to the minimum required version and run the command again.

Installed version: N/A
Minimum required version: 3
The version of powershell currently installed on this host is less than
the required minimum version. Please upgrade the installed version of
powershell to the minimum required version and run the command again.

Installed version: N/A
Minimum required version: 3
INFO interface: Machine: error-exit ["Vagrant::Errors::PowerShellInvalidVersion
", "The version of powershell currently installed on this host is less than\nthe
required minimum version. Please upgrade the installed version of\npowershell t
o the minimum required version and run the command again.\n\n Installed version
: N/A\n Minimum required version: 3"]

Example on windows 7, upgrade windows powershell to version 3 https://www.microsoft.com/en-us/download/details.aspx?id=34595 with vagrant_2.0.1_x86_64, and upgrade virtualbox to v 5.2.2 r119230