Jquery error please help me out

Hi guys,

Iam new to rails and jquery too..

now iam working on rails 3.1 v. in that i need to build one tab bar using jquery

$ gem list

*** LOCAL GEMS ***

actionmailer (3.1.0, 3.1.0.rc8) actionpack (3.1.0, 3.1.0.rc8) activemodel (3.1.0, 3.1.0.rc8) activerecord (3.1.0, 3.1.0.rc8) activeresource (3.1.0, 3.1.0.rc8) activesupport (3.1.0, 3.1.0.rc8) addressable (2.2.6) annotate (2.4.0) arel (2.2.1) attr_required (0.0.3) bcrypt-ruby (3.0.1 x86-mingw32) bson (1.4.0) bson_ext (1.4.0) builder (3.0.0) bundler (1.0.18) coffee-rails (3.1.1, 3.1.0) coffee-script (2.2.0) coffee-script-source (1.1.2) columnize (0.3.4) devise (1.4.7) diff-lcs (1.1.3) erubis (2.7.0) execjs (1.2.9) faraday (0.7.4) fb_graph (2.1.9, 2.1.8) haml (3.1.3) hike (1.2.1) httpclient (2.2.1) i18n (0.6.0) jquery-rails (1.0.14) json (1.6.1) linecache (0.46) mail (2.3.0) mime-types (1.16) mongo (1.4.0, 1.3.1) mongoid (2.2.2, 2.2.1) multi_json (1.0.3) multi_xml (0.4.1) multipart-post (1.1.3) mysql (2.8.1 x86-mingw32) oa-core (0.3.0) oa-oauth (0.3.0) oauth (0.4.5) oauth2 (0.5.1) orm_adapter (0.0.5) pakunok (0.0.3) polyglot (0.3.2) rack (1.3.4, 1.3.3) rack-cache (1.0.3) rack-mount (0.8.3) rack-oauth2 (0.11.0) rack-ssl (1.3.2) rack-test (0.6.1) rails (3.1.0, 3.1.0.rc8) railties (3.1.0, 3.1.0.rc8) rake (0.9.2) rbx-require-relative (0.0.5) rdoc (3.9.4) rspec (2.6.0) rspec-core (2.6.4) rspec-expectations (2.6.0) rspec-mocks (2.6.0) rspec-rails (2.6.1) ruby-debug (0.10.4) ruby-debug-base (0.10.4) sass (3.1.8, 3.1.7) sass-rails (3.1.3, 3.1.0.rc.7) sprockets (2.0.1, 2.0.0) sqlite3 (1.3.4 x86-mingw32) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) tzinfo (0.3.30, 0.3.29) uglifier (1.0.3) warden (1.0.5)

This is my Gem list.

<html> <head> <script type="text/javascript" src="#{Rails.root}assets/javascripts/application.js"></script> <script type="text/javascript"> $(document).ready(function(){ alert("welcome"); }); </script> </head> <body> </body> </html> my html code and

for this i need to get one alert message but iam not getting that please help me out.

Hey Venkat,

Did you added

add jquery.js into your app/assets/javascripts folder.

add these lines into layout and try. <%= javascript_include_tag ‘jquery.js’,‘application.js’ %>

Cheers, Sai

jquery-1.4.4.min.js (76.8 KB)

If he is using Rails 3.1 it’s not necessary to manually include the jQuery library using a tag. It’s also not necessary to manually include application.js like he is doing.

It’s better to use the asset pipeline.

Make sure your Gemfile contains the following line:

gem ‘jquery-rails’

Also make sure your app/assets/application.js includes the following line:

//= require jquery

And then when you use the following helper, jquery will be automagically included:

stylesheet_link_tag “application”

Check the guide on the Asset Pipeline for lots more information:

http://guides.rubyonrails.org/asset_pipeline.html

yaaa your right,Tim

Thanks, Sai