Wednesday, November 25, 2015

dbflow raw query

As example:

class Abc {
public static String get_latest_updated_at(Class model, String where, Object... args) {
    ColumnAlias[] alias = new ColumnAlias[1];
    alias[0] = ColumnAlias.columnRaw("max(updated_at) as updated_at");

    String query = "select max(updated_at) as updated_at from "+FlowManager.getTableName(model);

    Cursor cursor = FlowManager.getDatabaseForTable(model).getWritableDatabase().rawQuery(query, null);
    if(cursor.getCount() > 1)
        return "";
    return cursor.getString(cursor.getColumnIndex("updated_at"));


calling example:
Abc.get_latest_updated_at(Address.class, "")

//where by Address is model extending BaseModel

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


you may extends from Spree::BaseController