Creating an API with Rails [closed] - ruby-on-rails

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am just wondering what is the best approach in creating a RESTFUL API in Rails? Should I use Rails-API or Grape gem? What are the benefits/disadvantages of each? Is there a better alternative approach?

The good news is you can create REST APIs in Rails easily without either gem. There's a lot that goes into REST, so I don't think I can completely answer your question here. Fortunately, if you following Rails' conventions, you probably already have a REST API.
It looks like both of those gems are intended for cases where you are not using Rails. Rails-API says "The main example for its usage is in API applications only, where you usually don't need the entire Rails middleware stack nor template generation." Grape is designed for Rack applications, which offer a tiny bit of what Rails has to offer.
I would suggest taking a look at the book "Restful Web Services" by Richardson, Ruby, and Hansson. He does a good job of explaining REST and its advantages. The examples are in Rails, so it'll give you a great start to answering your question. I really enjoyed it and found it helpful in creating REST services in Rails.

Related

Ruby on Rails API Query [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am looking at creating a basic Rails application that can access this API http://instructure.github.io/ I have had a look through the documentation but cannot find anywhere I can get to grips with unfortunately. I am fairly new to Rails but I understand the basics. I was wondering if anyone knows of a good tutorial or resources where I can learn how to build a rails application that calls a third party API and displays the results. I know Canvas Instructure API is via JSON requests. Any information would be very much appreciated.
I would like to note that it uses Oauth2 for API authorisation for requests.
I would take a look at Httparty gem, It should do everything you need to consume an api
Here's an example of using omniauth and Httparty to connect to a 3rd party api
YOu can also take a look at oauth-plugin - https://github.com/pelle/oauth-plugin - which gives you both OAuth Provider and Consumer. Implementing the consumer should give you what you need.

What are the benefits of using Grape in the Rails app? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have a Rails web app and I want to provide API. I have found Grape and it looked nice and it can also be mounted into Rails but I am not sure of benefits of mounting Grape into my Rails app and use it for API instead of Rails controllers.
As I understand Grape is great for building applications that provide only API but it is not my case.
What do you think are the benefits of using Grape in the Rails app and why should I do so?
Grape within Rails makes it easy to standardize the syntax of your API.
For example, parameter validation and coercion, error handling specific to your API that's different than what Rails provides out of the box, and easy shortcuts for typical responses.
You could do all this with Rails, of course. Grape just makes it easy.

how useful is metaprogramming for building website with ruby on rails or django? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I started learning ruby on rails few weeks ago. I don't completely understand metaprogramming yet, but first I want to ask whether metaprogramming is worth learning if I only want to use ruby on rails to build websites. The example I see for metaprogramming is for generating undefined class method on the fly, but is it necessary?
My background: I use python on a daily base for scientific computing and have limited experience with django.
Metaprogramming is by no means a requirement to writing websites.
If you're beginning to program in Ruby, it's probably best not to worry about it until you're much more familiar with the language. The added flexibility it affords you comes at the expense of complexity and obscurity.
It depends entirely on the functionality of the website. Learn the basic idea of meta programming , then carry on with what you're doing. You'll then know if you are trying to solve something that meta programming would help with, and you can dig in more.

What are the signs that I *shouldn't* use Ruby on Rails for a project? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I've started learning RoR and I really like it - but it feels like it's oriented in one specific way - a very basic MVC model.
Which type of web application might not benefit from using RoR? Are there any signs I can find while planning the architecture?
I don't think there's a specific technical reason not to use RoR - it's fast, clean and can probably do anything PHP does.
The only reasons I can think of are the same consideration as to any other technology : Do you have the right people, is the legacy code (if any) compatible, are you in a market that makes it easy to find RoR people to support the code, and so forth.
There's also a nice Quora thread about this question :
If you have to install your website on a client machine that does not support rails/ruby.
If your code needs to be maintained afterwards by people that do not have rails knowledge.

What are some good resources for learning the Rails codebase internals? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have been developing in Rails for about 3 years now, and would like to learn more about the Rails internals themselves. Rails 3 supposedly provides nice API's for integrating more closely with Rails, but I'm having a hard time finding documentation on how to use them. Here are some examples of what i'm looking for:
Rails Initialization Process
http://guides.rubyonrails.org/initialization.html
Arel Walkthrough
http://railscasts.com/episodes/239-activerecord-relation-walkthrough
Routing Walkthrough
http://railscasts.com/episodes/231-routing-walkthrough
http://railscasts.com/episodes/232-routing-walkthrough-part-2
Crafting Rails Applications
http://pragprog.com/book/jvrails/crafting-rails-applications
Are there any other good resources that an help as a guided tour of how Rails works?
(and please don't say read the source code.. I'm looking for a more guided explanation)
You may like this articles:
http://piotrsarnacki.com/2010/07/31/rails3-modularity/
http://piotrsarnacki.com/2010/06/18/rails-internals-railties/
But, you should start writing such articles by own, ie try to write how controllers instance variables are visible in views or prepare description of all rails modules and classes - this will make you much more familliar with rails.
The Ruby Metaprogramming Book has some chapters in the end teaching how ActiveRecord internals is made up.

Resources