by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 07:00

    dnesteryuk on cleanup-on-compilation

    one more thing (compare)

  • Jul 08 09:52

    dnesteryuk on cleanup-on-compilation

    do not override (compare)

  • Jul 08 07:10

    dnesteryuk on cleanup-on-compilation

    just to experiment (compare)

  • Jul 08 06:58

    dnesteryuk on cleanup-on-compilation

    introduce a finalize! method T… (compare)

  • Jul 08 06:50

    dnesteryuk on cleanup-on-compilation

    introduce a finalize! method T… (compare)

  • Jul 08 06:11

    dnesteryuk on cleanup-on-compilation

    introduce a finalize! method T… (compare)

  • Jul 07 21:55
    dblock commented #1515
  • Jul 07 18:32
    dnesteryuk commented #2081
  • Jul 07 17:50
    jonmchan commented #1515
  • Jul 07 14:32
    alexandrz commented #2081
  • Jul 07 14:31
    alexandrz commented #2081
  • Jul 07 14:30
    alexandrz commented #2081
  • Jul 07 14:16
    alexandrz opened #2081
  • Jul 07 13:14
    dblock commented #2080
  • Jul 07 13:10
    dblock commented #1515
  • Jul 07 10:02
    grape-bot commented #2080
  • Jul 07 10:02
    PragTob edited #2080
  • Jul 07 10:02
    PragTob commented #2079
  • Jul 07 10:01
    PragTob opened #2080
  • Jul 07 07:27
    PragTob commented #2079
Ryan Romanchuk
@rromanchuk
Thanks going to give it a try
anyone know how i can use grape's represent method with a roar module to pass a custom variable down, been RTFMing for a while and just don't see anything
i need to be able to access current_user in a roar template
Kasper Holbek Jensen
@kholbekj
Hey, I'm trying to write a DSL method for a custom versioning scheme, but I'm a bit confused about passing info to inside the endpoint. Say i have
module Grape
  module DSL
    module Configuration
      extend ActiveSupport::Concern
      module ClassMethods
        def version_list(versions)
          method_that_passes_stuff(versions: versions)
        end
      end
    end
  end
end

module API
  module V1
    class Example < Grape::API
    version_list([1,2,3])
    get "/" do
      versions = method_that_retrieves_stuff(:versions)
    end
  end
end
Alex
@snowcat-alex
Hello there! I am curious: what is the most idiomatic means to share code between resources? Is this pattern supported? I have many resources with similar methods and I would like to avoid repetition and simply express how they differ from a base resource "class".
Alex
@snowcat-alex
Perhaps this indicates I need to think about restructuring the API itself!
Anton Yordanov
@anton-yordanov
Hello everyone,
I'm building Rack Grape API and I'm wondering which is the best practice for code reloading in development.
Into the Grape docs there is recommendation to use grape-reload gem for that. But it seems to be a little bit outdated, because the latest commit is from Apr 9, 2015.
Can you share how you solve the code reloading ?
Sridhar B.S
@sriddbs_twitter
Hello people
I am using Grape API and devise gem as well in my application. How do I use devise within Grape API?? For example I want to register a user and I want to use devise to handle the registration but my API end point will be coming from Grape
Branko Arnaudovski
@brarnaudovski_gitlab
Hi all. I am trying to access the grape env params from Doorkeeper.configure block, to set up the resource_owner_authenticator. In the code I am storing the token from a custom Authenticator class to a env['auth_token']. But this env['auth_token'] is nil in the Doorkeeper.configure block. Any help on how to access this token?
Arda Karaduman
@c0ze

@sriddbs_twitter

previously I did something like this. create something like

        desc "login user"
        params do
          requires :email, type: String
          requires :password, type: String
        end
        post "/login" do
        # do your devise stuff here
        end

depending on where you mount this api, you can access it like

    POST       /v4/users/login(.json)
Arda Karaduman
@c0ze
@brarnaudovski_gitlab I am little bit unsure as to what you are trying to do, but could it be that the custom Authenticator class you have is not being instantiated when Doorkeeper.configure block is run ? Can you try making sure it is being loaded before Doorkeeper ? Just a guess.
Franklin Yu
@FranklinYu
Any help for ActiveRecord? I read the section https://github.com/ruby-grape/grape#activerecord-without-rails
Franklin Yu
@FranklinYu
The constant ActiveRecord::ConnectionAdapters::ConnectionManagement is not found. Is there any require to load it?
Franklin Yu
@FranklinYu
Anyone here? This room is not very active?
Peter Lauck
@griest_gitlab
does anyone know why grape route helpers are not available inside endpoints?
Ken Spencer
@IotaSpencer
Why am I getting a '405 Method Not Allowed' for a get request, I'm trying to do something close to
resource 'webhook' do 
  get ':hook_name' do
    project = SiteHook::Config.projects.find_project(params[:hook_name])
  end
end
dm1try
@dm1try
it means that the method being used by the client is not GET
maybe POST, you should check the logs
github uses POST their web-hooks, for example
Ken Spencer
@IotaSpencer
right, but I'm literally going to it in my browser and that's what it returns
@dm1try
http://127.0.0.1:9090/v1/webhook/iotaspencer.me.json
{"error":"405 Not Allowed"}
    resource do
      post '/webhook' do
        halt 403
      end
      resource '/webhook/' do
        get ':hook_name' do
          project = SiteHook::Config.projects.find_project(params[:hook_name])
          if project.nil?
            {message: 'project not found or private', status: 1}
          else
            {project: project}
          end
        end
      end
Ken Spencer
@IotaSpencer
Puma starting in single mode...
* Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://127.0.0.1:9090
Use Ctrl-C to stop
[2019-03-11 20:57:00 -0400] 127.0.0.1 - GET /webhook/iotaspencer.me.json
Exception `Grape::Exceptions::MethodNotAllowed' at /home/ken/everygit/site_hook/vendor/bundle/ruby/2.5.0/gems/grape-1.2.3/lib/grape/endpoint.rb:254 - Grape::Exceptions::MethodNotAllowed
dm1try
@dm1try
@IotaSpencer not reproducible on my side, feel free to create an issue
also you can check Allow response header, as described here https://github.com/ruby-grape/grape#allowed-methods
Ken Spencer
@IotaSpencer
is there a reason why i can't use a . in my route param eg /webhook/iotaspencer.me/
With the way I have my code and had my code before when i was using sinatra I could use /webhook/iotaspencer.me/ yet now with grape i can't seem to use it, I can only use the 'more valid' and final format i've chosen for how they are implemented internally, which is basically by taking any non valid url character and changing or removing them, so like spaces and . in project name and in the webhook call, are internally _
Ken Spencer
@IotaSpencer
meaning that yes, 'iotaspencer.me' and 'iotaspencer me' are the same project internally and as such would be validated as duplicate projects
Nitesh Sharma
@sinscary

Hi,
We have been using grape for a long time and thanks for such a great framework.

Below is how we set values for a param.

params do
        optional :my_column1, type: Integer, desc: 'some description', values: MyModel1.all.pluck(:id)
        optional :my_column2, type: Integer, desc: 'some description', values: MyModel2.all.pluck(:id)
end

Our database is shared between two services. The above two columns(my_column1 and my_column2) get updated by other microservice. And when someone makes a request using API, it fails with the error message "my_column1 does not have a valid value.". same goes for my_column2.

While debugging I realized that during booting of rails application these values are being set and it only gets updated when we restart the server next time.

What we want are these values to be updated dynamically. Which means every time we make a request, it should make a query to the database and set those values. I am having a very hard time figuring out how to do this, or even if it's possible with Grape.

Any help will be appreciated.

Kevin Elliott
@kevinelliott
Hey guys. I’ve got an endpoint that is loading a significant number of records (~15k) and then running them through the formatter. It’s bloating memory significantly (500-700MB per request) and causing big problems for us. Unfortunately NewRelic instrumentation doesn’t help us much (just clumps to Proc#call). The obvious fix is to add pagination and for the internal client to use pagination, but that’s not within our power at the moment. The endpoint is only building up an AR scope, then formatting the collection to JSON — no real magic here, no complex logic. What can I do to minimize (or even better, eliminate) this memory bloat?
matrixbot
@matrixbot
Peter Lauck
@griest_gitlab
options[:env] doesn't seem to always be available in grape entity, anyone know why?
I think its only available in root-level exposures, i.e. when I use present in my endpoints
Anton Yordanov
@anton-yordanov
@sinscary try with values: -> { MyModel1.all.pluck(:id) }
Paulo Daniel Carneiro
@PauloDanielCarneiro
Hello people.
Quick question.
Is there any way to debug a grape API?
Henry Tseng
@henrytseng
anyone using grape-swagger (testing with swagger-ui) have a way around issue: ruby-grape/grape-swagger#721
where the parameters are specified as in form - even when consuming json?
Mauricio
@banduk

Hi guys, just a quick question. Anyone know how to access original_fullpath from request?

https://apidock.com/rails/ActionDispatch/Request/original_fullpath

Ben Chiciudean
@benydc
I'm trying to create namespaced classes but I'm getting error from grape:
gems/grape-1.3.0/lib/grape/api.rb:85:inconst_missing': uninitialized constant Api::Base::V1 (NameError)`

this my base class in api folder:

module Api
  class Base < Grape::API
    mount V1::Base
  end
end

and in v1 folder I have:

module Api
  module V1
    class Base < Grape::API
      mount Currency
    end
  end
end
and my config.ru:
require 'rubygems'
require 'bundler/setup'

Bundler.require

require 'grape'

Dir["#{File.dirname(__FILE__)}/api/**/*.rb"].each { |f| require f }

run Api::Base
aki1221
@aki1221
Hi,
how to override initialize method with for_collection
currently if i override initalize method inside representor and using representer.for_collection.new(resource) not working while respresenter.new(resource) works fine
Phuc Nguyen
@nhphuc412
Hi,
anyone use grape in ruby on jets?
I see issue when use grape in ruby on jets. pls help to take a look
ruby-grape/grape#2009
aki1221
@aki1221

hi,
is it wrong to define a param in both route and param block like
params do
requires :id, type: Integer
end
get '/id' do

params[:id] is an Integer

end

Thomas Scholz
@tscholz
Hi, what is the best way to share code between different API projects, e.g. a collection entity or endpoint helpers?