Complete rails json API example with Rspec tests [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 4 years ago.
Improve this question
I'm looking for a good example repository of a Rails 3 project that implements a JSON API and has included RSpec tests. A full tutorial would be great but I'd settle for just a well commented example.

Yehuda Katz and Ryan Bigg's excellent upcoming book, Rails 3 in Action, has a chapter on building a test-driven JSON API on top of the example application that runs through the entire book.
While I strongly recommend buying a copy of the beta edition of the book, the code for the sample application, Ticketee, is open source and can be found on GitHub. In particular, everything API-related is namespaced under /app/controllers/api and you can find plenty of RSpec tests in /spec/api.
I was in your same position a couple of months ago when I was having to write a JSON API for an iPhone app so I'm well aware of the lack of good, test-driven, relevant tutorials online. Lucky for me I found out about the book and it turned out to be an absolute life saver.

RubyGems.org is open source and has a great example of an API

Can't necessarily answer the api example, but I can definitely vouch for the API testing of a rails 3 app in processes.
Here you go: whitneytaylorimura.wordpress.com
It has a full example using Cucumber, Rspec, & FactoryGirl to create your objects (with DatabaseCleaner to clean them up).

Related

Looking for an intermediate to advanced Rails 3 book recommendation [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 8 years ago.
Improve this question
I'm a seasoned Symfony 1.4 developer with a good handle on Symfony 2.0, so I'm a bit beyond the basics of frameworks.
I've recently built a solution with Rails 3 and would like to pick up a book to read up on how I could have done some things better.
I'm mostly using Rails as a database layer with very minimal in the ways of ERb. Some topics I'd hope to see covered in advanced detail are:
JSON
Ideas and opinions on how to serve rich internet applications
Good ActiveRecord usage and planning
Writing models and keeping implementation out of controllers
In general, conventions on controllers and actions
There are likely many subjects I'd like to hear about however I'm not interested in focusing too strongly on testing quite yet.
Haven't read this book, but it seems really good Ruby Science
After spending a bit of time with some of the books from the comments above, it looks like Rails Antipatterns is still quite worthwhile.

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...

Can anyone recommend a beginning Ruby on Rails tutorial that doesn't rely on scaffolding? [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've just started learning Ruby on Rails, and all the tutorials and books I've used rely on scaffolding to get started. I've written two simple apps but I still can't figure out how to independently write a database-driven app without using scaffolding, and yet from what I've read online most professional Rails developers don't use it. Are there any tutorials that would help a newbie create their first app without scaffolding?
This one http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/ is pretty good and helpful.
"Rails 3 in Action" is a good resource (I've even bought it ;)), one thing I hate about it is a sort of enforced usage of Cucumber.
Cucumber is a great tool, worth mentioning, but it is used all over the book and it clutters the narrative terribly. I would like to have Cucumber-free version of the book and I belive that most beginners would prefer the same.
Ruby on Rails Tutorial by Michael Hartl: http://www.railstutorial.org/
Best resource for Rails learning I've come across, whether in paper or online.
I'm currently writing a book called Rails 3 in Action that sounds like it would "answer" your question.
Whilst the first chapter does cover scaffolding (just for a "quick win"), the rest of the book goes through and teaches you how to develop an application using the exact same process that people in the real world do.
You'll learn Rails, Cucumber and RSpec, along with the other gems that we pick up along the way of developing the application.
Give it a shot and let me know what you think.
Check out some of the older Railscasts.

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.

How to auto generate Rails REST API documentation for controllers? [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
How to automatically generate API documentation for Rails REST controller?
Is there any example I can look into using RDoc to do this?
You can try apipie-rails which I created: https://github.com/Pajk/apipie-rails/
It can do more things than just generate documentation, more info on https://github.com/Pajk/apipie-rails/.
I found https://github.com/zipmark/rspec_api_documentation to be a really nice tool. It's driven off of rspec acceptance tests so you're writing documentation at the same time you're writing acceptance tests! Double win!
Use rapi_doc gem. The setup is very simple and straight forward. Follow this tutorial: http://www.rubyglob.com/generating-api-documentation-with-rapi_doc/
You can use "calamum" a ruby build program to generate a nice html api doc from yaml file definition.
https://github.com/malachheb/calamum
Although is not automatic, I define and document my APIs using RESTful API Modeling Language or, RAML.
There are Node.js packages that turn the yaml file into a nice looking html documentation, like raml2html.
I was also searching for a good documentation tool which can be easily integrated into rails. Finally we built our own rails engine APIDOCO
However it does not auto generate the documentation but you can easily use it.

Resources