Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert Assign Ruby varaible to Javasc...

Replytotopic

Assign Ruby varaible to Javascrip variable

Posted in Forums : Ask a Rails expert

 
Photo

Authority 0
Posting Rating 0
Sign in to rate this post

how can i assign assign Ruby variable to Javascrip variable
var userid =<= username = session[:user].id>;

didn’t work.

 
Avatar

Authority 12
Posting Rating 0
Sign in to rate this post

var userid = <%= session[:user].id %>; should work

 
Profile

Authority 37
Posting Rating 0
Sign in to rate this post

If you’re building a response in your controller you can also do it like so:

update_page do |page|
  page.assign "userid", session[:user].id
end

Replytotopic

Other Recent Topics

Ask a Rails expert : how to check processs is running or stop

Ask a Rails expert : Routing problem using patterns for id

Ask a Rails expert : How to work with ror 2.1.1 using Netbeans IDE 6.1

Ask a Rails expert : json gem error

Ask a Rails expert : Problem with break

Ask a Rails expert : activesupport string first method error

Ask a Rails expert : url_for broken ?

Ask a Rails expert : map.routes.rb pls help

Ask a Rails expert : how to h tag in controller

Ask a Rails expert : Problem with Restful routing and partial form

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel