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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:58:55+00:00 2026-05-28T07:58:55+00:00

My experience with rails and Javascript is very limited. I am trying to pop

  • 0

My experience with rails and Javascript is very limited.

I am trying to pop up a basic alert function to make sure everything is in working order however its not working therefor things are not in working order!

When the index page is loaded run this code every single time:

$(document).ready(function() {
 alert('Welcome to index!');
});

That code is currently located in a file in assets/javascript/default.js

In my application.html.erb, in the header I have added

  <%= javascript_include_tag :default %>

and in my controller under index format I have also added

format.js { render 'default.js'}

when I run the page with firebug under scripts it does see

<script type="text/javascript" src="/assets/default.js?body=1">

although I dont understand the body=1 part yet, and under scripts it does show the code, so clearly the browser can see the code however for some reason is not executing it.

In my gems i have jquery-rails(1.0.19) and bundle install has already been run.

I have tried that page with firefox, internet explorer, and chrome to no avail. and I apologize if I have already missed such a question.

I thank you all for your time.

  • 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-28T07:58:55+00:00Added an answer on May 28, 2026 at 7:58 am

    In Rails 3.1, you should be using 'application', not 'default':

    <%= javascript_include_tag :application %>
    

    This will load the app/assets/javascript/application.js file which is really just a manifest to load all your other javascript files, including jQuery:

    // This is a manifest file that'll be compiled into application.js, which will include all the files
    // listed below.
    //
    // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
    // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
    //
    // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
    // the compiled file.
    //
    // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
    // GO AFTER THE REQUIRES BELOW.
    //
    //= require jquery
    //= require jquery_ujs
    //= require_tree .
    

    It loads jQuery, then the require_tree . line loads all other javascript files.

    With your code as it is, jQuery is never loaded, so it doesn’t understand the $ function.

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

Sidebar

Related Questions

I am working on a rails application (I have some experience with rails). But,
My experience with MySQL is very basic. The simple stuff is easy enough, but
My experience with application servers is limited to some basic servlet coding, so I
I am working on a rails application that uses big javascript libraries (e.g. jquery
My sql experience is a bit limited, but my Rails is on point. I'm
I just started using CakePHP for a small project. I have rails experience, and
I do have experience with Ruby on Rails, and am programming a project in
Hey, i have some experience with MVC. but I'm new to rails. I'm using
I am just getting into Grails having had some experience with Rails, and I
While I have experience developing Rails apps in English, I am a blank slate

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.