I researched migration command in CakePHP 3.
Continue reading CakePHP 3 migration commandYearly Archives: 2015
CakePHP3 How to use partial template like in Rails
Now I will explain how to use partial template in CakePHP 3, which is created like Rails. The Japanese document of CakePHP 3 is not up to date, but English document is.
Continue reading CakePHP3 How to use partial template like in RailsRails How to execute task in seed
Here’s how I executed task in seeds.rb
, in Rails.
Environment
- Ruby 2.2.2p95
- Rails 4.1.8
- Rake 10.4.2
First, create a task with rails g task sample shot
. The following code will be generated.
1 2 3 4 5 6 |
namespace :sample do desc "shot sample" task shot: :environment do # something to do end end |
Now, we can execute the task with bundle exec rake sample:shot
. The goal is to execute the task when bundle exec rake db:seed
is executed. Maybe, it is the same way to execute task in rails code.
Solution
Add the code into seeds.rb
, like below.
1 2 |
ENV['SOMETHING'] = 'value' Rake::Task['sample:shot'].invoke |
Environment (test, development, production) is passed, which is valid in rake db:seed
. On the above, set 'value'
to SOMETHING
. It is like FEATURES in rake db:fixture:load FIXTURES=xxxx
.
CakePHP3 How to stop auto increment on auto generated id column
I researched how to stop auto increment of auto generated id column in CakePHP3.
Continue reading CakePHP3 How to stop auto increment on auto generated id columnShow japanese in xterm
Japanese letter is sometimes shown in incorrect way on xterm. In case that you use ubuntu with Japanese font. Here, I introduce how I made it available to show Japanese letter. (The way is also available for uxterm.)
Edit Menu
Launching xterm with some option solves the problem. So, change xterm command on menu. If you use LXDE or Gnome etc., you can change menu with property window opened by right-clicking the menu. On the dialog, change the command to xterm -fwb Sans
, then wide bold letter displayed in Sans font,
In my case, I use openbox and wanted to change “Terminal emulator” menu item, which open LXTerminal, to xterm, then followed the steps below.
1 2 |
mkdir -p ~/.config/openbox cp /etc/xdg/openbox/menu.xml ~/.config/openbox |
Then I was ready to change menu and changed the execution command of “Terminal emulator” in ~/.config/openbox/menu.xml
to xterm launching command with options.