Monday, November 23, 2015

undefined local variable or method `try_spree_current_user'

If you create your custom spree controller,

beware that you will need to add in some spree controller helper to make the magic works

include Spree::Core::ControllerHelpers::Auth
include Spree::Core::ControllerHelpers::Store
include Spree::Core::ControllerHelpers::Order

or

you may extends from Spree::BaseController





Friday, October 23, 2015

authorize! for update

just realize calling model.update after authorize! is wrong!

the right way is to run an authorize!, then model.assign_attributes, then rerun authorize! again, 
and finally model.save

Tuesday, October 20, 2015

running rvm based cron job

rvm is requires a bash login to work.
in order to execute cron jobs, run this:

*/5 * * * * 'sh /home/myuser/versions/current/runme.sh'

create a shell file,
change working directory to rails root,
and run the required job, such as delayed_job once and exit

vi /home/myuser/versions/current/runme.sh
cd /home/myuser/versions/current
/bin/bash -l -c 'RAILS_ENV=production bundle exec rake jobs:workoff'



Thursday, October 1, 2015

speeding up vagrant and virtualbox synced folder on mac and windows


On MAC:
first, use nfs for sync folder,

in Vagrantfile:
web.vm.synced_folder "/private/var/www", "/var/www", type: "nfs", mount_options: ['rw', 'vers=3', 'tcp', 'fsc', 'actimeo=2']

actimeo=2 # increases speed of file sync

then do a: 
vagrant reload




On Windows:
web.vm.synced_folder "c:/wamp/www", "/var/www", type: "smb"

Notes: nfs on windows is not fully compatible. On linux guest machine, it does not allow file locking. This isn't good enough with rails, especially. Smb is an good option with file locking support, and fast response time. But this requires running command prompt as administrator to start smb command.


Hope it helps ;)

Friday, August 28, 2015

installing volley for android

Latest volley is available in maven repository,
therefore, you do not need to compile volley from source code.
goto Build > Library and dependencies > dependencies
click + add, search for volley
com.mcxiaoke.volley:library-aar:1.0.1


If you insists:
---old stuff---
Follow instruction here:
http://www.androidhive.info/2014/05/android-working-with-volley-library-1/

but first, makesure you have setup your environment and paths:

PATH=$PATH:/path-to-android-sdks/platform-tools:/path-to-android-sdks/tools:"/Applications/Android Studio.app/Contents/gradle/gradle-2.4/bin"

export ANDROID_HOME=/path-to-android-sdks

(Please change the path-to-android-sdks and gradle version accordingly)

for windows, you may use SET instead of export.
example: set PATH=%PATH%;...

And,

instead of using ant to build, use `gradle build`.
didnt work for me, i tried to use android studio to open the project, and did not manage to get it compiled...

Thursday, July 30, 2015

connecting to sql server with rails

sql server / sql express is by default cannot be connected by a fixed port
to login to sql server, first, assign a password for sa user,
or any user, and map the database to the user.
you may use db_owner for default role mapping.

then open sql configuration manager
select sql server netwrok configuration > Protocols for localhost / express / your instance name
select TCP/IP
scroll to bottom, and set:
all ports: 1433
dynamic port: (empty, not even a zero)
then goto control panel > services > sql server
restart service,
enable sql browser (auto start delayed) and start service

this shall help to make it work with rails or tiny_tds

Monday, July 20, 2015

mariadb 10.0 upgrade from 5.5

Upgrading to Mariadb10 seems to fail on my ubuntu 14 virtualbox.
What i did was restart the instance,
followed instruction from:
https://mariadb.com/kb/en/mariadb/upgrading-from-mariadb-55-to-mariadb-100/

and prompt to replace my my.inf configuration with maintainer configuration.
but it still failed.
tail -n 200 /var/log/syslog turn out that it was unable to bind at 127.0.0.1.

so i vi /etc/mysql/my.inf
change the binding address to 0.0.0.0

and it works :)