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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:08:44+00:00 2026-05-11T18:08:44+00:00

I have a little piece of rails code which lets users enter a review.

  • 0

I have a little piece of rails code which lets users enter a review. If one already is written it displays the current review with a link to edit it.

      <div id="text_area">
        <% if @user_rating.review.blank? %>
          <%= render :partial => "reviews/text_area" %>
        <% else %>
          <%= simple_format @user_rating.review %>
          <%= link_to_function "Edit Review" do |page|
            page.replace_html :text_area, :partial => "reviews/text_area"
          end %>
        <% end %>
      </div>

This works correctly EXCEPT if the review contains a double quote character. Here is the HTML output it generates after a user has already written a review (the else block from above).

      <div id="text_area">
          <p>some text with "quotation marks"</p>
          <a href="#" onclick="try {
Element.update(&quot;text_area&quot;, &quot;&lt;form action=\&quot;/pages/iphone-reviews/reviews/new/write\&quot; class=\&quot;edit_rating\&quot; id=\&quot;edit_rating_16\&quot; method=\&quot;post\&quot;&gt;&lt;div style=\&quot;margin:0;padding:0\&quot;&gt;&lt;input name=\&quot;_method\&quot; type=\&quot;hidden\&quot; value=\&quot;put\&quot; /&gt;&lt;input name=\&quot;authenticity_token\&quot; type=\&quot;hidden\&quot; value=\&quot;fSZK30kpWEUtCxOvr4xDF1O+puDiPm87mhaxaLirIT8=\&quot; /&gt;&lt;/div&gt;\n        &lt;textarea cols=\&quot;40\&quot; id=\&quot;rating_review\&quot; name=\&quot;rating[review]\&quot; rows=\&quot;20\&quot; style=\&quot;width:100%;height:150px;\&quot;&gt;some text with &quot;quotation marks&quot;&lt;/textarea&gt;\n&lt;/form&gt;&quot;);
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.update(\&quot;text_area\&quot;, \&quot;&lt;form action=\\\&quot;/pages/iphone-reviews/reviews/new/write\\\&quot; class=\\\&quot;edit_rating\\\&quot; id=\\\&quot;edit_rating_16\\\&quot; method=\\\&quot;post\\\&quot;&gt;&lt;div style=\\\&quot;margin:0;padding:0\\\&quot;&gt;&lt;input name=\\\&quot;_method\\\&quot; type=\\\&quot;hidden\\\&quot; value=\\\&quot;put\\\&quot; /&gt;&lt;input name=\\\&quot;authenticity_token\\\&quot; type=\\\&quot;hidden\\\&quot; value=\\\&quot;fSZK30kpWEUtCxOvr4xDF1O+puDiPm87mhaxaLirIT8=\\\&quot; /&gt;&lt;/div&gt;\\n        &lt;textarea cols=\\\&quot;40\\\&quot; id=\\\&quot;rating_review\\\&quot; name=\\\&quot;rating[review]\\\&quot; rows=\\\&quot;20\\\&quot; style=\\\&quot;width:100%;height:150px;\\\&quot;&gt;some text with &quot;quotation marks&quot;&lt;/textarea&gt;\\n&lt;/form&gt;\&quot;);'); throw e }; return false;">Edit Review</a>

      </div>

This example breaks because the text of the review contains a double quote. It works with single quotes and any other text I can think of. I think rails is not escaping the double quote correctly in the javascript.

The error which comes up in Firebug is this:

missing ) after argument list
[Break on this error] \” id=\”rating_review\” name=\”rating[re…n:right;\”>\n

I’m at a loss on how to fix this one. 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-05-11T18:08:44+00:00Added an answer on May 11, 2026 at 6:08 pm

    Found a solution which worked. I’m not really sure why it worked but it did.

    A couple times up above I call a partial to render the text area and form where the user can edit their review, like this

    <%= render :partial => "reviews/text_area" %>
    

    All I had to do was go in and edit this partial. One of lines in the form looked like this:

    <%= f.text_area :review %>
    

    All I did was change it to this:

    <textarea cols="40" id="rating_review" name="rating[review]" rows="20"><%=@user_rating.review%></textarea>
    

    Basically just put it in manually so it didn’t use the rails function to generate the text area. For whatever reason, it works now. May be something that could be improved in the rails text_area function.

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

Sidebar

Related Questions

I have a very simple little piece of Lua code, which I wrote while
I have this little piece of jQuery/jqModal code which works fine. However, I am
I have a little piece of code which populates a CellTable from a Type
I have a little piece of code which reads a file and i want
I have this little piece of code that just checks for a particular text
Let's say I have this little piece of code: <?php $tmp = str_split('hello world!',2);
So I have made a little piece of code that will insert and manipulate
I have some function (pasted below little piece of function), which I used as
So I have this little piece of code: System.out.println(Size: + mounts.keySet().size()); for (JHttpPath entry
I have a short little piece of code to play tones via Tao.Sdl. It

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.