2 Replies Latest reply on Jun 20, 2012 8:08 AM by Brandon Headrick

    Can't figure out how to call Ruby functions from .erb files.

      I need to call ruby functions from my index.erb file, and I can't seem to get it to work properly.  I'm using the index.erb and controller.rb from this resource as a reference: https://github.com/rhomobile/rhodes-system-api-samples/tree/master/app/SystemTest


      Here's a snippet from my Project/app/index.erb and my entire Project/app/controller.rb file  (note: the controller.rb is a file I explicitly created because I didn't see one that existed prior).


      index.erb: (where I'm trying to call the is_app_installed function)

      <% if System::get_property('platform') == 'ANDROID' %>


           <%= link_to 'Is App installed?', url_for(:action => :is_app_installed) %>



      <% end %>



      require 'rho/rhocontroller'

      class RhoElementsAppController < Rho::RhoController


        def is_app_installed

            installed = System.app_installed?('com.example.helloandroid')

            Alert.show_popup(installed ? "installed" : "not installed")

            redirect :action => :index





      I have another app installed on my device with the package com.example.helloandroid and I'm testing this on the Android simulator, not rhosimulator, that has that app installed.  When I execute this, no alerts come up to signify that it has executed the code either way.


      I am very new to ruby, so excuse me if I'm doing something naive.