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
0
votes
1 answer

How do I force Grape to accept and return only JSON?

How do i restrict my API to accept & respond only json format on Rails & Grape, i've try format :json on my Grape controller and (for example) i can access it on example.com/api/v1/ping.json, but i also can access it via example.com/api/v1/ping.xml,…
user876349
0
votes
0 answers

How to pass query string and POST params in grape

I am using grape Restful API. I want to create a post method with POST parameters and Query string parameters. How to use them? Can anybody give me a nice example? I know to pass Query string params(key, sign) as follows. but how to use POST…
Sam
  • 5,040
  • 12
  • 43
  • 95
0
votes
0 answers

Grape::API – RuntimeError: Circular dependency detected while autoloading constant User

I'm testing the Grap API framework with Rails 4.1, but I'm stuck on this circlar dependency. Any idea why I get it? app/api/v1/user.rb module V1 class User < Grape::API format :json desc 'Returns pong.' get :user do { ping:…
martins
  • 9,669
  • 11
  • 57
  • 85
0
votes
0 answers

Sinatra app with Grape API

I'm running a Sinatra App along with Grape. I've seen other postings on SO in about how to run the two together or any other Rack compliant solutions, though my quandary is a bit different. I would need to preface that most solutions I've noticed…
Wojtek
  • 63
  • 3
0
votes
1 answer

Hashie::Mash stored as string and unable to extract it back

I am using Grape and storing data in postgres hstore data field. But the problem is that it stores the Hashie::Mash as string and not as object. data_hash = {'top_key' => {'key1' => 'val1'}} db_obj = Model.find(1) …
Mr. Bless
  • 285
  • 4
  • 10
0
votes
1 answer

ActiveRecord::Base has_many fetch all for a given parent

Question Below I give my current API result, however, given the SQL that is executed it isn't my Expected or Desired Result. Can anyone assist me in getting the second SQL queries results instead of the first? Models console_game.rb class…
abc123
  • 17,855
  • 7
  • 52
  • 82
0
votes
0 answers

Problems renderingJSON posts with Ember frontend, Sinatra racked with Grape backend

currently I'm having a little trouble rendering my JSON posts in ember, the structure of my app has my config.ru file at the front, another public folder with all the ember content inside. The app works, it just won't render the posts, it worked…
Neal
  • 573
  • 3
  • 16
0
votes
1 answer

Rspec testing API with rack protection

I am trying to test my API with an rspec integration(request) test. I go to my api endpoint at 0.0.0.0:3000/api/regions in a browser and it returns my data, I get a session id and looks like everything is working. I am using rack protection in my…
Stan Bondi
  • 4,118
  • 3
  • 24
  • 35
0
votes
1 answer

Syntax for declaring resource paths in Grape

I am looking for clarification on the syntax to declare API resource paths in Grape. The example below declares the resource paths "/items", "/items/:id", "/objects", and "/objects/:id". What I do not undestand is why the definition for "/items/:id"…
mph
  • 68
  • 2
  • 5
0
votes
1 answer

How to present one namespace model with grape-entity?

I have one namespace model like this : class Message::Notification < Message end And I define one entity like this: class Message::Notification < Grape::Entity expose :id end There is a error when present the model: present @notification,…
why
  • 23,923
  • 29
  • 97
  • 142
0
votes
1 answer

Generate JavaScript using the Grape API?

I am using the Grape framework to retrieve data, which is working great. I would also like to retrieve a JavaScript file using the API. For example: