Phonegap App communicate with Rails 3 App using authentication
The answer was two fold.
First I had to add this to my ajax requests in the iOS app:
xhrFields: {
withCredentials: true
}
as in...
$.ajax({
url: ....,
type: "GET",
xhrFields: {
withCredentials: true
},
complete: hideLoader,
error: function(xhr,txt,err) {
// you can't get back anyways
window.location.hash = "";
},
success: function(data,status,res) {
window.location.hash = "";
}
});
Second I had to add this to my Application Controller in the Rails app:
def protect_against_forgery?
unless request.format.json?
super
end
end
Using Phonegap as a native container for a Rails 3 App
I do not believe such a container exists to run on the client side but it is possible to dynamically serve a PhoneGap app (i.e. the app acts as a web browser with native functionality available via javascript commands).
Here is code which demonstrate exactly what you are describing.
Here is a screen cast I did associated with demo.
NOTE: The demo is using an out 3.2.1, and is broken as of the latest version Xcode and/or PhoneGap but it is possible, and apps of this nature are valid in the the various app stores, (Linkedin alongwith many others are already doing it.) The logic is there I just haven't had the time to fix the bug with the new version of Xcode, or update the PhoneGap code (doing the update may actually fix the bug in one quick work session).
Related Topics
Rake: Logging Any Task Executing
Naming Conventions for Boolean Attributes
Get Available Diskspace in Ruby
Validate That a Value Is in a Certain Range, E.G. 1 <= Val <=2
How to Find Out the Starting Point for Each Match in Ruby
Prawnto Displaying Tables That Don't Break When New Page
In Depth Ruby Gem Development Resources (Book, Video, Sites)
Can Multiple Sidekiq Instances Process The Same Queue
Approach for Installing System Service Implemented as Ruby Gem
Get Time from Datetime Variable in Ruby
Why Does Array#Each Return an Array with The Same Elements
Ruby on Rails Looks for CSS in Assets Instead of Public/Stylesheets
Fastest Way to Find a String into an Array of String
Factory_Girl + Rspec Doesn't Seem to Roll Back Changes After Each Example