Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8386215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:52:29+00:00 2026-06-09T17:52:29+00:00

I develop api for my rails project and don’t now how to solve this

  • 0

I develop api for my rails project and don’t now how to solve this problem

I use doorkeeper gem for authentication and rabl gem for json rendering. And i have to add some fields only for logged user.

For example: part of show.rabl:

node :accessible, if: lambda { |m| current_user } do |model|
  model.accessible(current_user)
end

And api/application_controller.rb:

def current_user
  User.find(doorkeper_token.resource_owner_id) if doorkeper_token
end

I also tried this way (rabl file) :

if current_user
   node(:accessible) { |m| m.accessible(current_user) }
else
   {no: "no"} # this line rendered!!
end

And rabl doesn’t know anything about my method and return false in if lambda.
How can i solve this problem? i ready for any suggestions. Thank you!

i use rails-3.2.6 doorkeeper-0.4.2 rabl-0.6.13

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:52:31+00:00Added an answer on June 9, 2026 at 5:52 pm

    You can try:

    • setting an instance variable in your controller instead of using current_user
    • or rendering a different file wether the user is logged in or not (and use rabl partial to avoid duplication)

    I’m also using rabl and doorkeeper so keep me up to date if you find a good solution 😉 I might need to do the same soon.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When you use Twitter API and develop your first simple Twitter client, and post
I am using RPXnow.com authentication solution for a rails app and am now at
I want to use the FaceBook Graph API to develop some apps (I won't
I want to develop Safari plugin using xCode, What API should I use? Someone
I am new to api development, so don't know whether this is feasible or
i've been struggeling with this all day now I want to make an API
I am making use of Java Mail API to develop an app to send
I want to develop a web application and I have access this API. In
I am start develop on Bing Map application using Ajax control api. Does this
I am trying to develop a paint brush application thru processingjs. This API has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.