Training
From Rhomobile
Contents |
Rhomobile Training
This is the outline of the Rhomobile training course. It attempts to build a simple app in the course of several lessons. You can use our existing tutorial backend (rhostore) or interact with your own backend app that exposes an Internet accessible protocol. We would like to see students make headway with their own envisioned app
Prerequisites
Knowledge and Expertise
Students must understand HTML (creating web pages) and Ruby. They must have developed at least one app in Ruby before coming to this class.
Installed Software
Students must all have the following installed on their Mac or Windows laptops and bring those laptops to class
- iPhone SDK OR the Android SDK
- please also sign up for a RhoHub account at http://rhohub.com
Lesson 1 - Starting with Rhodes
- Time: 10am
Lecture
Describe Rhogen. Demonstrate app generation with two models. Hook into a simple top page.
Exercise
- RhoGen simple app with two models
- build for iPhone or Android as these are the simplest build process (whichever is the student's preferred environment)
Lesson 2 - Synchronizing Data to a Backend
- Time: 10:45am
Lecture
How to generate a RhoSync source and do basic query and create
Exercises
Students will all add basic read (query) syncing to their backend app as well as creating records
- generate a source adapter skeleton with rhogen
rhogen source Customer
- create a query method as follows:
def query
parsed=nil
open("http://rhostore.heroku.com/products.json") do |f|
parsed=JSON.parse(f.read)
end
@result={}
parsed.each {|item| @result[item["product"]["id"].to_s]=item["product"]} if parsed
@result
end
- create a create method in your source adapter as follows:
def create(name_value_list)
attrvals={}
name_value_list.each { |nv| attrvals["product["+nv["name"]+"]"]=nv["value"]} # convert name-value list to hash
res = Net::HTTP.post_form(URI.parse("http://rhostore.heroku.com/products/create"),attrvals)
end
- Modify your config.rb in your customer model (set the "url"=> value to "Customer")
Rho::RhoConfig::add_source("Customer", {"url"=>"Customer", "source_id"=>683})
Lesson 3 - Adding Device Capabilities
- Time: 11:30am
Lecture
Vlad will describe the PIM contacts API and GPS API.
Exercises
Save to PIM Contacts
- you can do this with another button on your edit.erb form with a different value such as "Save to contacts"
- conditionally check in your Contact controller update method for the "Save to contacts" button and then do the contact save
- Specifically save to contact with Rho::RhoContact.create!(@params['customer']) in your controller update method
- see http://www.youtube.com/rhomobile#play/all/uploads-all/0/IbvTYx6LTKQ for adding PIM contacts example
Use GPS
- add "find nearby customers" into the app. Use the Haversine distance function
- create the nearby function in the controller.rb file
- add code to index.erb to invoke nearby
Perform Build
- build for chosen SDK
Lunch
- lunch will be provided at 12:15pm and the instruction will have a 15 minute break
Lesson 4 - Building for Different Operating Systems
- Time: 12:30pm
Lecture
Brian will describe how to do builds for iPhone, BB, Windows Mobile and Android, along with some demonstrations of the process and the various options.
Exercise
Students will create builds of their app for all operating systems which they have installed locally. Students should have at least a second device SDK installed
Conclusion
The formal class will end at 2pm. Students may opt to continue working until 3pm on premises and ask questions of Rhomobile engineers.
