title: How to pass parameter in .js.erb render file and get
body: <p>I am developing <code>rails 4 application</code> where i have to render <code>.js.erb file</code> from controller.</p>
  
  <p>Now i have to pass parameter from controller to .js.erb file and use that parameter to that file.</p>
  
  <p>Controller:</p>
  
  <pre><code>  if @user.user_settings == nil
        render "save_account_settings.js.erb", :locals =&gt; {:msg =&gt; "Your account settings saved successfully"}
    else
        render "save_account_settings.js.erb", :locals =&gt; {:msg =&gt; "Something goes wrong. Please try again."}
    end
  </code></pre>
  
  <p>Above code from controller and I have to pass parameter to .js.erb file and use it.</p>
  
  <pre><code>File:  save_account_settings.js.erb
  
  $('#saved_message').text('&lt;%=params[:msg]%&gt;');
  </code></pre>
  
  <p>But not working for me.</p>
  
  <p>Where is i wrong. Need to change file name or something else.</p>
  
  <p>Thanks</p>