Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Going from ruby on rails web application to native iphone app

I was wondering how people do this, or if they even do it? Say I have a site like facebook, and then want to also have an iphone app based on the website which was built using rails. How do you go about going from the rails web app to the iphone app and accessing the rails databases and such without having access to rails.

1 Answer

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hi Stone,

Rails allows you to serve up different formats of the same data. For example:

/articles
/articles.json
/articles/1
/articles/1.json

You would use something like the respond_to method in your controllers and instead of serving up HTML you'd serve up JSON for the iPhone to read and display the data in the views on the phone.

You should check out some of the documentation on serving up different data formats.

http://apidock.com/rails/ActionController/MimeResponds/InstanceMethods/respond_to

Regards
Andrew