2015年5月6日水曜日

vagrant upに失敗する

vagrant upすると起動できなくなった。
$ vagrant up
The provider 'virtualbox' that was requested to back the machine
'default' is reporting that it isn't usable on this system. The
reason is shown below:

VirtualBox is complaining that the kernel module is not loaded. Please
run `VBoxManage --version` or open the VirtualBox GUI to see the error
message which should contain instructions on how to fix this error.
カーネルモジュールがロードされてないっぽい。

言われるままに実行。
$ VBoxManage --version
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (3.13.0-52-generic) or it failed to
         load. Please recompile the kernel module and install it by

           sudo /etc/init.d/vboxdrv setup

         You will not be able to start VMs until this problem is fixed.
4.3.26r98988
なんかWARNINGでた。

言われるままに実行、再。
$ sudo /etc/init.d/vboxdrv setup
Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modulesError! Could not locate dkms.conf file.
File:  does not exist.
 ...done.
Trying to register the VirtualBox kernel modules using DKMSError! DKMS tree already contains: vboxhost-4.3.26
You cannot add the same module/version combo more than once.
 ...failed!
  (Failed, trying without DKMS)
Recompiling VirtualBox kernel modules ...done.
Starting VirtualBox kernel modules ...done.
カーネルモジュールをリコンパイルしてスタートdone。

これで、vagrant upできるようになた。

[Rails]InheritedResources::Baseを継承したコントローラーになってしまう

scaffoldしたコントローラーがInheritedResources::Baseを継承したものになってたので原因調査。

結論としては、activeadminの依存で入ったgem inherited_resourcesの影響。
ActiveAdmin's use of Inherited Resources overrides `rails g scaffold my_articles` #3114
config.app_generators.scaffold_controller = :scaffold_controller
をconfig/application.rbに追加しろとのこと。

やりたいことを簡単に実現できる反面何してるのか良く理解できていないことが多い。
Rails 奥が深い。

2015年5月5日火曜日

[Rails]rake db:resetとrake db:migrate:reset

Ruby on Rails チュートリアルで知ったrake db:resetを何の疑問も持たずに使っていたが、activeadminを使っていて少々困ったので調べてみた。