Questions tagged [ruby-grape]

Grape lets you quickly add maven repository dependencies to your classpath OR Grape is a REST-like API micro-framework written in Ruby to sit on top of Rack.

Grape is a framework that allows for quickly defining REST-like interfaces in Ruby. It provides a DSL for defining versioned APIs as a collection of entities mounted on Rack.

385 questions
23
votes
3 answers

User Authentication with Grape and Devise

I have difficulties to understand and also properly implement User Authentication in APIs. In other words, I have serious problem to understand the integration of Grape API with front-end frameworks such as Backbone.js, AngularJS or Ember.js. I'm…
Tom Hert
  • 947
  • 2
  • 10
  • 32
16
votes
1 answer

Why am I getting "Unable to autoload constant" with Rails and grape?

I want to do an API for an Android app. When searching, I found {grape}. I'm following this tutorial, but I have a problem launching the Rails server: => Booting WEBrick => Rails 4.0.2 application starting in development on http://0.0.0.0:80 => Run…
HatsuMora
  • 194
  • 1
  • 8
10
votes
3 answers

How to handle before filter for specific action in Grape?

I'm mounting Grape in my Rails project to build a RESTful API. Now some end-points have actions need authentication and others which don't need authentication. As for example I have users end-point which looks something like: module Backend …
Eki Eqbal
  • 5,779
  • 9
  • 47
  • 81
10
votes
5 answers

Ruby Grape JSON-over-HTTP API, custom JSON representation

I have a small prototype subclass of Grape::API as a rack service, and am using Grape::Entity to present my application's internal objects. I like the Grape::Entity DSL, but am having trouble finding out how I should go beyond the default JSON…
Neil Slater
  • 26,512
  • 6
  • 76
  • 94
9
votes
1 answer

How to get routes by Grape API

I use gem, grape for api. I tried to get api urls by the command rake grape:routes namespace :grape do desc "routes" task :routes => :environment do API::Root.routes.map { |route| puts "#{route} \n" } end end but I…
Hiromu Masuda
  • 259
  • 1
  • 3
  • 14
9
votes
1 answer

Why ActionDispatch::Routing::RouteSet takes so long

I am using Grape on top of Rails 4.2.1 to provide API for our application. But when I check Newrelic for performance today I found that RackApp Proc#call and Grape API::Root#call are taking up large amount of time. (See the screenshot) Then I…
larryzhao
  • 3,173
  • 2
  • 40
  • 62
9
votes
1 answer

Grape error handling strategy?

I am using Grape and Rails to create a REST API. I have the basic architecture in place and I am looking for places to 'clean' things up. One of those places is the error handling/processing. I am currently rescuing errors in the root.rb (GRAPE::API…
mfunaro
  • 574
  • 6
  • 23
9
votes
2 answers

how to get the remote ip (requester) on grape-api rails application

I have a working rails application with grape-gem working as an end point for some APIs in the application. I need to get the remote ip for the requester and return it back in the response. I could do that on regular controllers…
alybadawy
  • 489
  • 2
  • 7
  • 13
8
votes
1 answer

Uploading multiple files in the same request

I need to create a POST where I can upload multiple files in the same request, but I don't know how to write this with grape. Right now to upload just one file this is what I'm doing and It's working fine: desc 'Creates a new attachment.' params do …
Andres
  • 11,439
  • 12
  • 48
  • 87
8
votes
1 answer

RestSharp Accept header change

I am using RestSharp for developing on the client side. I am also using Ruby Grape gem for my custom API on server side. Grape gem can do versioning by setting Accept HTTP header f.e to application/vnd.twitter-v1+json And test command via console…
Ihor
  • 91
  • 1
  • 1
  • 6
7
votes
0 answers

Grape entities and Single table inheritance

Let's say i have Base class "Attachment < ActiveRecord::Base" and 2 child classes "Attachment::Video < Attachment" , "Attachment::Image < Attachment". present Attachment.all, with: API::Entities::AttachmentEntity But i want to use different…
Yegor Razumovsky
  • 902
  • 2
  • 9
  • 26
7
votes
0 answers

Swagger documentation not available when subdomain

Using the grape-swagger gem, I've setted a subdomain on Grape Swagger as such in routes.rb constraints subdomain: /api/ do mount Api::V1::Base => '/' end And here is document.rb require 'grape-swagger' module API class Root < Grape::API …
sidney
  • 2,704
  • 3
  • 28
  • 44
7
votes
4 answers

remove quotes from returned string of grape api

I want to return raw data/blob from my grape/rest api. I followed the thread at : https://github.com/intridea/grape/issues/412 for a code like : get 'foo' do content_type 'text/plain' "hello world" end 1) I used : format 'txt' - I got quoted…
resultsway
  • 12,299
  • 7
  • 36
  • 43
7
votes
2 answers

JSON to ActiveRecord (deserialize)

I'm building a web API with Ruby, Grape and ActiveRecord. Coming from ASP.NET Web API I'm used to having automatic model binding from JSON to a class object which then can be saved with Entity Framework. I have been searching a bit to find out if…
Abris
  • 1,451
  • 3
  • 18
  • 38
7
votes
2 answers

Grape: required params with grape-entity

I'm writing an API server with grape and i choose to use grape-entity because it has the capability to auto generate the documentation for swagger. But now i have a problem when i set a param as required. Because grape don't validate that the param…
Spike886
  • 609
  • 8
  • 23
1
2 3
25 26