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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:50:22+00:00 2026-05-31T13:50:22+00:00

The RailsTutorial Exercise 10.5.7 asks me to insert a character counter for the micropost

  • 0

The RailsTutorial Exercise 10.5.7 asks me to insert a character counter for the micropost form. I’m using this plugin to accomplish the task.

Everything is working, except the character count div is being inserted twice, as you can see in the following screenshot.

Two character count divs

I suspect this is happening because I’m using the form_for tag, which takes a block. Here’s the page code:

<%= javascript_include_tag "character-counter", "character-counter-options" %>
<%= form_for(@micropost) do |f| %>
  <%= render 'shared/error_messages', object: f.object %>
  <div class="field">
    <%= f.text_area :content, placeholder: "Compose new micropost...",
                              id: "new-micropost" %>
  </div>
  <%= f.submit "Post", class: "btn btn-large btn-primary" %>
<% end %>

I can post the javascript if needed, but like I said, things are working correctly except for the duplication. I haven’t changed any of the plugin code, just my options following the examples included in the plugin source. All of this can be found in the link from the first paragraph.


Update: Here is the javascript I’m using. The plugin code is long, so I opted to put it in a paste. InsertAfter appears in line 38 of the paste. My options are also in the past, but since they’re short, you can read them here as well.

var info;
$(document).ready(function(){
    var options = {
        'maxCharacterSize': -2,
        'warningStyle' : 'warning',
        'warningNumber': 40,
        'displayFormat' : '#input/140'
    };
    $('#new-micropost').textareaCount(options);
});
  • 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-31T13:50:23+00:00Added an answer on May 31, 2026 at 1:50 pm

    It turns out, since I was including the javascript in the asset pipeline, it was being loaded twice. It was loaded once by the asset pipeline, and then again in my form partial (see the first line of the template code in my OP).

    See: $(function) gets called twice in Rails 3.2.1 App

    I don’t really need the code on every page, just in that partial, so I’ll move the files out of the asset pipeline. : /

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

Sidebar

Related Questions

I'm following this tutorial http://ruby.railstutorial.org/ The tutorial seems to be using Rails 3.0. I
I'm working on chapter 11 of Michael Hartl's RailsTutorial and I got this error
I am practicing this RoR tutorial project of Michael Hartl: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book I am using
I'm having trouble with Exercise 4 in Chapter 7 of railstutorial.org . Here are
I'm following Railstutorial.org and gets MassAssignment Error when using Rspec. 10) User when email
I am trying to learn Ruby on Rails using this Rails Tutorial. Earlier, I
I am learning rais from the rails tutorial book: http://ruby.railstutorial.org/chapters/sign-in-sign-out#fnref:9.14 I am working on
I'm working through http://railstutorial.org (currently working on section 10.4.2 - destroying users). My User
im going through the setup on http://www.railstutorial.org/chapters/static-pages#fig:autotest_green and im stuck on this particular error:
I'm currently working my way through http://www.railstutorial.org/ It uses Rspec along with a TDD

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.