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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:31:41+00:00 2026-06-06T00:31:41+00:00

I think this is easily explained by looking at code, so I’m posting a

  • 0

I think this is easily explained by looking at code, so I’m posting a couple of snippets that show how I usually do Ajax things in Rails 3.2,

The following will work:

create.js.coffee

$("<%= raw j(render(partial: @comment, locals: { str: 'string' })) %>")
  .appendTo("ul#comments")

_comment.html.haml

-puts "The variable's value is #{str}"
%li= comment.what

Now, I’d like to do the same as above, but instead of passing a JS string literal, I’d like to pass an object literal, like this:

create.js.coffee

obj = 
  'v1': 'value'
  'v2': 'value'

$("<%= raw j(render(partial: @comment, locals: { o: obj })) %>")
  .appendTo("ul#comments")

Which of course fails with the following reason:
ActionView::Template::Error (undefined local variable or method `obj’…

Does anybody know how to accomplish what I’m trying to do? Is it possible at all?
Let me know if what I’m trying to do is insane, and what would be the proper way if that’s the case..

Thanks!

  • 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-06T00:31:42+00:00Added an answer on June 6, 2026 at 12:31 am

    Well I guess clients objects are not shared with server object, unless untill we are doing remoting. So in this case you have to serialize JS object into JSON or any other string format (XML or any other structure) and then you have to de-serialize in Ruby object or you can manually parse the string and use the information provided.

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

Sidebar

Related Questions

I think this code For Each file in filecoll Ext = UCase(Right(File.Path, 3)) If
Just googling 'TDD' and 'GWT' easily lead to this article where the author explained
I think this is probably a fairly easily answered question: Im new to regular
I think this could be a very easy question for you. But I have
(I think this is a pretty basic question on OOP, but unfortunately I wasn't
I think this is a simple and a silly question. I have included a
I think this is nearly impossible or very tricky. I'm using CriteriaBuilder, JPA 2.0,
I think this is a pretty straightforward problem but... var outerHeight = $('.profile').outerHeight(); $(#total-height).text(outerHeight
I think this is mostly because I'm new to PHP OOP, but I have
I think this question has been asked many a times but I've been searching

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.