random technical thoughts from the Nominet technical team

Prototype and script.aculo.us problems in Rails 1.2

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 2.5 out of 5)
Loading ... Loading ...
Posted by jay on Mar 2nd, 2007

Whilst working through the examples in the “Ajax on Rails” book I had all sorts of problems with Prototype and script.aculo.us. For a start, there is a simple example of a link that toggles a div between visible and invisible, like this:

<%= link_to_function "Toggle DIV", "$('indicator').toggle()" %>

But all I got with this was the error message “toggle is not a function. I even tried replacing toggle() with show() and got another error. Eventually I upgraded from Prototype 1.4 to 1.5 and the problem went away.

Now all through this, script.aculo.us had been working fine. But then I tried another simple example:

Effect.toggle('indicator', 'blind')

Again I got the error message that ‘toggle is not a function’. So this time I upgraded script.aculo.us to 1.7 and it all seems to work fine.

Having said that all I’ve done is upgrade within my current project so now I need to work out how to upgrade the prototype and script.aculo.us built into Rails so that all new projects start with the new versions.

2 Responses

  1. Gary Says:

    Rails 1.2 ships with prototype 1.5 and Scriptaculous 1.7 so if you upgraded to rails 1.2 and created a new rails project then you should have them in the public/javasctips directory of your project.

    If you created a project with an older version of rails and then upgraded rails then this will not replace the javascript files in your project.

    There are two ways to do this.
    First, modify your config/environments.rb file to set the RAILS_GEM_VERSION variable to your new version of rails (1.2.2 at the moment)
    Then run
    rake rails:update:javascripts
    to update the javascript files in the public/javascripts directory.

    Another way (but probably more risky since it affects the whole project) is to run
    rails .
    in the project directory. This will then give you the option to replace out of date files. BEWARE that if you’re not careful you may replace files that you have modified losing your work!

  2. WebGK.com Says:

    I think this has been taken care of in the latest version of Rails.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Recent Posts

Highest Rated

Categories

Archives

Meta: