including jQuery library

Hi. I have started Rails a few days ago. With the help of a book (written in Japanese), I'm working on a tutorial program which simply shows how to include jQuery file.

Rails version 3.1.3

According to the book, there must be a directory

public/javascript

but there isn't after launching a new project. But I finally found the directory

app/assets/javascript

so I copied jquery.js and rails.js in there.

and in "application.rb"

    config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

and in "application.html.erb"

<!DOCTYPE html> <html> <head>   <title>OnlineDictionary</title>   <%= stylesheet_link_tag "application" %>   <%= javascript_include_tag :defaults %>   <%= csrf_meta_tags %> </head> <body>

<%= yield %> </body> </html>

and finally in" test.html.erb"

<img id="logo" src="http://www.wings.msn.to/image/wings.jpg&quot; /> <script type="text/javascript">   $('#logo').fadeOut(3000); </script>

so if success, it should fade out the image. It shows the image but it does not fade out. It does not work at all.

Could anyone point out the mistake(s) I presumably made?

soichi

Hi. I have started Rails a few days ago.

With the help of a book (written in Japanese), I’m working on a tutorial

program which simply shows how to include jQuery file.

Rails version 3.1.3

According to the book, there must be a directory

public/javascript

If I’m not wrong, in rails 3.x that folder no longer exists

and in “application.rb”

config.action_view.javascript_expansions[:defaults] = %w(jquery

rails)

and in “application.html.erb”

OnlineDictionary

<%= stylesheet_link_tag “application” %>

<%= javascript_include_tag :defaults %>

Normally I use <%= javascript_include_tag “application”%> because it will get all the js that comes from the folder assets.

Now my question is… what version of rails that book is using?

Javier

Find a tutorial that matches the version of rails that you are using, otherwise you will never know whether troubles you encounter are due to real problems or that the tutorial is incorrect for your version of rails. railstutorial.org is good and free to use online.

Colin

Thanks everyone.

The book is using Rails 3.0.5.

And I changed to

<%= javascript_include_tag "application"%>

then the finally generated page seems to includes the jquery.js as I wished. But it does not fade out...it seems weird.

I will check the tutorial page you suggested. Thanks.

soichi