Ruby on Rails API Tutorial [closed] - ruby-on-rails

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I've never worked with or written an API before. To help me learn, I want to write a Facebook API library RubyGem.
I'm thinking I should start with learning how to write a simple API with RoR.
Do you know of any good resources or tutorials that will help me learn how to write an API with Ruby?

I think you'll first have to chose what is exactly that you want to learn, since there's quite a few parts to this.
A gem such as facebooker is used to consume the API of a web service rather than "create" or expose an API (for a web service). In order to understand a library like this and what it does, you could try to learn more about APIs in general, but also about ways to access them using Ruby.
Even though Rails and the Rails community are embracing RESTful (or actually RESTlike) APIs, there are a bunch of other forms around as well, such as SOAP. Facebook e.g. has ditched REST in favor of their graph API. Check the answers for this question, which deals with the different types, to learn more: Examples of the best SOAP/REST/RPC web APIs? And why do you like them? And what's wrong with them?
For ways to access (REST) APIs I'd suggest taking a closer look at the source code of gems such as e.g. HTTParty and rest-client as well as Ruby's standard library Net::HTTP.
What comes to API's and web services, I've heard good things about "Restful web services" but there's a whole bunch of books and about a gazillion blog posts out there on this topic. Google is your friend.
And then you'll probably want to have a look at the development of ruby gems in general. This answer might give you some pointers in this regard: Ruby : How to write a gem?
This is an endless topic and I suggest to just get started somewhere. Learn how APIs work, how to access them and then read lots and lots of source code, e.g. of Facebooker or one of the other Facebook API gems. See how they work and start writing code. Good luck!

http://8raystech.com/2009/10/06/a-real-life-restful-rails-application
[edit]
The above link is broken.

Related

What Web app chores, can be eliminated using Plugins/Gems in Rails [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I've been building Rails Application Prototypes and Loving it. I'm aware that there are many pre-build libraries to utilize in projects.
While, I'm not a fan of using plugins for managing login and user authentication, which is core part of the app, aside from that what other chores can be dealt with plugins/gems, like pagination etc.
What do you use in your day to day rails development.
There are times when using freely available plugins/gems (libraries) may not be suitable but since it is quite trivial to review the code of these, in the long run you will find that many of these gems can be quite handy. A lot of these are also actively kept up to date by the community and this is also an important point as Rails in particular has been evolving at a fairly rapid pace.
For example, Devise has been around for quite sometime and if you look at the amount of support this tends to translate into a commensurate number of blog articles and how-to's on the web; even here on SO Devise in particular gets many questions. It also has many modules that you can incorporate within your app, or just disable if you do not require their functionality.
Rather than going into the benefits of plugins, I suggest you visit http://rubygems.org/ as it let's you go through the various gems based on their particular functionality.
Personally, I use Devise as well as authentication from scratch, Omniauth, Kaminari (pagination), CanCan for ACL and quite a bit more. This is the Gemfile from one of my recent apps and it should give you a decent idea of what I use.
Being familiar with popular gems is quite handy as it means rather than having to 're-invent the wheel', when it simply comes to getting the job done... you do have options - especially when it's not the sole purpose of your app. Certainly though, if you're up to creating custom plugins or decide to pull out reusable code into plugins, do share them with the community.
Hope this helps!

How to interact with a CalDAV server from Ruby? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I need to create events on a calendar server using CalDAV from within a Ruby (Rails to be precise) Application. I have looked at some different libraries and done some googling.
I looked at ri-cal ( http://ri-cal.rubyforge.org/rdoc/ ) But wasnt sure if it supported sending data toa server or if I had to do that myself,
this looked promising http://www.local-guru.net/blog/pages/rubycaldav , but it says it is alpha software, i need something stable.
What is the best way to do this? Is there any library that does this already, Do i need to form my own HTTP requests?
Any advice on the subject is appreceated
I ended up using the library at http://www.local-guru.net/blog/pages/rubycaldav
I had to adapt it work with SSL, and use the UUID library correctly, format the dates correctly and work with Full day events. Since I only needed to create and destroy Events that is all i updated. I plan to do more with in when i have time.
My updated code can be found here https://github.com/loosecannon93/ruby-caldav.
The problem I was having was supplying incorrectly formatted dates, and lack of UUIDs.
The caldavtest.rb file on GitHub is what I used to work
An additional Complication i ran into was that Zimbra ( the server ) has 2 paths, one for ICS files that are readonly /home/user#host/Calender and one for CalDAV /dav/user#host/Calendar
I hope that someone may find help with this solution.
However there is a substantial lack of cladav implementation for Ruby. There are ICS libraries that form objects, but there is only pure Net::HTTP to interact with a server. Local-guru's is the only ruby one I found that works both ways, but it is in need of some help with minor issues.
I fixed some of these but not project wide, I just had to get it working. But if someone would like to contribute I would love to help.
One of my favorite places to check for possible options is on Ruby Toolbox. This would be one of the first places I would check.
I would also check github, which yielded this result which may be your best option and just what you are looking for.
As far as answering your other questions, I would probably roll my own after taking a look at both this post and this code.
So, long answer severely shortened, yes there are libraries that already accomplish what you are looking to do, but if it were me, I would roll my own solution for something this specific.
are you hosting your calendars on google? if you are, then take a look at: https://github.com/northworld/google_calendar
We've used caldav4j as our app was deployed in JRuby. Don't know whether thats an option for you.

Tutorials or screencasts on building a REST web service on Rails [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am looking to build a REST webservice on Rails to serve as the server side component to my mobile app. Can someone point out some tutorials or screencasts on building REST webservices for someone who is learning Rails?
The main features I am looking for are:
Authorization(user id and password validation).
Posting data from the client (mobile app) to the server database using REST API
I am also okay if you could point me to some book where content on creating a rest api is available.
It would also be great if someone could post a bit of code to get me started on this.
I am relatively new to Rails and have almost finished the book "Ruby on Rails Tutorials" by Michael Hartl. This is my only experience with Rails, so far.
Thanks.
I wrote 2 blog posts that you'll probably find helpful:
http://davidsulc.com/blog/2011/04/10/implementing-a-public-api-in-rails-3/
http://davidsulc.com/blog/2011/04/17/consuming-a-public-rails-api-with-jquery/
They're not tutorials, but it should get you going.
The basic idea is: expose JSON data through controller actions when a request is made with the .json format.
Cross domain requests (like the ones you'll be doing from your mobile app) are a little trickier, as explained in the blog post: you'll actually need to send javascript within a callback, or your code won't work (you'll get an empty response). (Explained in the first post.)
Once the data is exposed as JSON, simply query it from your mobile app (as explained in the 2nd post).
EDIT: Manning has a book on Rails 3 (one of the authors being none other than Yehuda Katz) with a chapter on creating an API: http://manning.com/katz/ In particular, it covers token authorization for the API using Devise.
I'd suggest you visit Railscasts. If you search on various keywords you'll get a wealth of information. I used 'REST', 'routes', 'controller' to get myself started...

Using FourSquare API in a Rails App [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Anybody have any good resources that might be helpful in trying to integrate the FourSquare API into a Rails app? I'm specifically looking for a good tutorial. There doesn't seem to be much out there yet. There are a few ruby gems, but they are pretty bare bones and I need a bit more hand-holding.
Here is a resource that I've found so far:
http://tedgrubb.com/
Stack Overflow won't let me include a second hyperlink, but you can also google: Foursquare ruby gem for another resource.
I have not done much work with APIs in the past, but I am very comfortable with Rails. What I need is a little better sense of exactly where all the pieces fit. A basic tutorial is what I'm looking for.
Thanks.
This helped me. It's a working example of a Rails project integrated with FourSquare:
https://github.com/pierrevalade/foursquare-rails-examples
Quimby is an excellent ruby api wrapper:
https://github.com/groupme/quimby
It was built by GroupMe.
'foursquare2' Ruby wrapper for the foursquare v2 API
Refere this : https://github.com/mattmueller/foursquare2 which is good & helped me a lot.
You can able to get more foursquare API data as user less and with authenticated user also
by using the 'foursquare2' gem.
The foursquare-API gem seems like the only one out there that supports V2 of their API and seems like the best place to start.
This isn't an answer, but this may be a start:
http://stakeventures.com/articles/2009/07/21/consuming-oauth-intelligently-in-rails
http://developer.foursquare.com/docs/oauth.html
I'm having trouble implementing a 4sq rails app myself.

Is there anything that explains the Rails' API documentation? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I know that http://api.rubyonrails.org/ is meant to explain methods etc in ruby on rails, but I need something that explains the explanation to me. It seems like a good resource, I'd like to understand it or perhaps it's time to give up.
I think this might be what I was after
Reading the API
I suggest you try some light reading first. Quite a few Rails tutorials exist.
As the URL indicates, this is API documentation. You use it for reference, not for learning about the language or framework. This is not specific to the Rails API, but for just about every framework out there.
I suggest you follow a few Ruby tutorials and then start on a few Rails tutorials first.
http://www.ruby-lang.org/en/ should get you started on Ruby. I won't bother linking to Rails tutorials, but http://railscasts.com/ is an excellent place to start once you get a basic Rails app up and running.
After that, the Rails API will start making a lot more sense.
http://api.rubyonrails.org is definitely not what I would call newbie friendly. Here's some places to go for more information:
railsapi.com -- Same idea but way better presentation, easier to navigate. Use this like you would msdn.com: a reference for things you already know about, but need to look up the particulars.
guides.rubyonrails.org -- This is geared much more towards new users in a tutorial format.
railscasts.com -- Short demonstrations of particular features and plugins in screencast format.
Of course if you have any specific questions about the framework you've already come to the right place.
I recommend at http://www.railsbrain.com and http://railsapi.com/doc/rails-v2.3.5/ as better ways of navigating the docs.
Another good source would be apidock.com
Contains lots of examples on how to use each rails feature.
In addition the same site also provides documentation for Ruby
This one has a lot of good examples: http://www.tutorialspoint.com/ruby-on-rails-2.1/rails-quick-guide.htm

Resources