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 7871145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:49:17+00:00 2026-06-03T01:49:17+00:00

I have a web app which is part Rails and part Backbone . Some

  • 0

I have a web app which is part Rails and part Backbone. Some things such as a commenting system I have implemented are written mostly in Javascript on the client side. The Rails backend simply handles persistance by passing JSON back and forth.

When I render pages from the server, handling who gets to see what is easy. I can say things such as

<li class="comment">
  <span class="comment_text"><%= @comment.text %></span>
  <% if user_signed_in? and current_user == @comment.author %>
    <a class="delete" href="some delete url">Delete Comment</a>
  <% end %>
</li>

And that will only render the link to delete a particular comment if the current user is the comment’s author. No problem.

However, now that I’m rendering comments on the client side using JavaScript templates (which are cached afaik), I don’t have access to current_user. I can’t tell if the user currently using my app is the author of the comment or not so I can’t control what he gets to see.

Sure, he won’t be able to delete the comment either way because I authorize on the server as well but I’d rather not show hin the link in the first place.

How can I accomplish this?

I’d love some links to resources on this topic as well as answers because I can’t seem to find any, even though it seems to me like this is a topic that should have been covered in countless blogs.

  • 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-03T01:49:18+00:00Added an answer on June 3, 2026 at 1:49 am

    I prefer using following approach.

    First, in your layout, generated on server-side, pass current user’s data that you’ll need on client side:

    <script type="text/javascript">
        window.currentUser = {
            id : "<%=current_user.id%>"
        }
    </script>
    

    It will be accessible in your EJS templates. Now in template, you can make the same check as on server-side:

    <% if (window.currentUser && window.currnetUser.id == comment.author.id) { %>
        <a class="delete" href="some delete url">Delete Comment</a>
    <% } %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASMX service which serves some partial-HTML to a web-app as part
I have written a web app in PHP which makes use of Ajax requests
I have a Rails app whose major part is to query another web-service using
I have a web app which works, for the most part with MRI Ruby
I have a web app which connects to a server using a TCP connection
I have a web app which lets the user select the excel spreadsheet and
I have a Flash web app which displays user submitted PNG files. Files are
I have a Silverlight web app which uses ASP.net Website administration tool for user
Have an ASP.net web app which works fine for a few days, but then
I have an existing HTML5 web app which I am going to port to

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.