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

  • Home
  • SEARCH
  • 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 7653529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:03:21+00:00 2026-05-31T12:03:21+00:00

I am trying to call a ruby method from erb file. This method takes

  • 0

I am trying to call a ruby method from erb file. This method takes one parameter. This parameter value is entered by user in a form. How do I send this as argument to the method?

something like this works. i.e when I send string instead of variable

<% construct('Text')%>

But how to send variables? i.e I need something like this

<% construct(Variable)%>

My variable is javascript variable

var Variable = Search.val();

Should I create a ruby variable before passing? Any example code for this will be really helpful

  • 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-05-31T12:03:22+00:00Added an answer on May 31, 2026 at 12:03 pm

    I feel like there’s a fundamental flaw in how you think ruby works…

    Ruby is a server-side language, and javascript is a client-side language. The ruby code in a Ruby on Rails application sends the client (A user’s browser) the HTML, Images, CSS, and other assets it needs for a user’s browser to display what they need to see. Javascript is only viewed by the browser, and Ruby code is only viewed by your server (Which the browser has no knowledge of).

    You cannot use a javascript variable to send to a Ruby method. You either need to re-implement your helper method in javascript to get the functionality you need, or you need to perform an Ajax request to get the javascript to make a request to your server, which your Ruby on Rails controller can then handle and give the appropriate response to.

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

Sidebar

Related Questions

I am trying to write a Ruby script in one file. I would like
I have a new MacRuby application. I'm trying to call a MacRuby method from
Easy one for Tuesday morning... Im trying to call a javascript function from inside
I'm trying to call a web service from Excel 2003 module. The way i've
How do you call the method of an included class in Ruby? See the
I am trying 'mongo-ruby-driver' for some project. It's working fine except when I call
I am new to Ruby and currently trying a few examples from the Ruby
Coming from a long history of C-style syntax and now trying to learn Ruby
I am trying to learn Ruby, and want to implement the Python algorithms from
I'm trying to override a method located in a Gem in Ruby/Rails, and I'm

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.