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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:25:55+00:00 2026-06-08T15:25:55+00:00

In ruby one can do something like <%= form_tag(:action => ‘/submit’) do %> …

  • 0

In ruby one can do something like <%= form_tag(:action => '/submit') do %> ... <% end %> to get a form including CSRF tokens.

Is there an existing function in node and how is it implemented?

  • 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-08T15:25:56+00:00Added an answer on June 8, 2026 at 3:25 pm

    You can use caolan-forms plugin for node.js. After that install express-csrf plugin.

    Then you can merge these two, something like:

    // initializing express
    var express = require('express'),
    
    // initializing express-csrf   
    csrf = require('express-csrf');
    
    app = express.createServer();
    
    app.dynamicHelpers({
        csrf: csrf.token
    });
    
    var forms = require('forms'),
        fields = forms.fields,
        validators = forms.validators;
    
    var reg_form = forms.create({
        username: fields.string({required: true, id: csrf, name: csrf}),
    });
    
    // finally render the form
    reg_form.toHTML();
    

    It would produce:

    <div class="field required">
       <label for="id_username">Username</label>
       <input type="text" name="[csrf-value]" id="[csrf-value]" value="test" />
    </div>
    

    Note: The caolan-forms’ author wrote:

    You’ll notice you have to provide your own form tags and submit button, its more flexible this way 😉

    Edit

    Since express-csrf is depriciated, instead use connect bundle and follow this simple example. Eventually, you would be able to integrate it with caolan-forms like:

    var reg_form = forms.create({
         '_csrf':fields.hidden({value: 'req.session._csrf'}),
          ...
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Normally to use Ruby libraries from command line I can do something like: ruby
In Ruby, can I do something C-like, like this (with my made-up operator '&'):
With OS X Xcode installed one can run ruby code in terminal with >ruby
Can any one tell me? what does following means in ruby program: obj =
Am new to ruby. Can any one tell me how to find inverse of
How can I specify a custom action for a nested URL in ruby on
I understand that in order to sum array elements in Ruby one can use
I'd like to add something like a callback function to a Ruby array, so
I have created one ruby script that I want to run with some flags
I have VPS with 1GB of RAM. One ruby-app that runs on thin server

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.