Recent Changes - Search:

CIS 700

Ajax

Ruby

Rails

Second Life

Navigation


Penn PmWiki

pmwiki.org


edit SideBar

Problems and solutions

This page is for posting problems--and solutions, if you know them. If you encounter a problem (for example, getting some installed software to work), post your problem here. If you can supply a solution to a posted problem, please do so.


Problem: Tk doesn't work in my version of Ruby.

Solution: [Updated August 7]
It turns out that Tk is not included with InstantRails or with the Ruby One-Click Installer. The numerous Tk files are only the bindings for Tk. You can download Tk itself (along with Tcl), from http://www.activestate.com/Products/ActiveTcl. After you install ActiveTcl, restart your Ruby IDE; Tk will be available.


Not Really a Problem: Moreso a helpful hint This one is a few days late, but might be useful for anyone who intends to do more Google mashups. Looks like Google has a beta mashup editor, with limited access right now. Check it out here:

Google Mashups Editor


Problem: For the rails assignment, any ideas on how to use sorting? Should this be done through helper classes, or does it make sense to try using the Ruby sort functions in any way? Should a sort class function be implemented in one of the model classes?

Possible solution: If you're talking about sorting items from the database, you can do it from withing the database using the :order option of the find method. For example: Student.find(:all, :order => "name DESC")

You can also use the order option with has_many: has_many :students, :order => "name DESC"

Of course, you could always toss in some SQL joins if you want to sort by attributes in other tables, like student.grade

If you need to do a sort that for some reason the database can't do, you can use a facade method in the model. So for example, in the Course model you could have:

has_many :students

def students

  students = read_attribute("students")
  # sort and return students

end

Then in the controller you could call course.students and get back the students in whatever order you specified.


Problem: I can't find the GUI to view my database in Instant Rails.

Solution: Right-click your Instant Rails icon in the System Tray. Select "Configure > Database (via PhpMyAdmin)" to administer your databases through your web browser.


Problem: Working on the mashup project, I've learned that IE and FireFox treat XML differently. Firefox doesn't seem to ignore newlines between the tags, whereas IE does. For example

<coordinates>
  <coordinate>
    <id>FISM</id>
    <name>The Franklin Institute Science Museum</name>
    <latitude>39.9580</latitude>
    <longitude>-75.1732</longitude>
  </coordinate>
</coordinates>

if I use the following after loading the XML into JavaScript:

x = xmlDoc.getElementsByTagName('coordinate');
id = x[0].childNodes[0].firstChild.nodeValue;
alert(id);

IE returns 'FSM', whereas Firefox returns nothing. To get Firefox to return 'FSM', I have to use:

id = x[0].childNodes[1].firstChild.nodeValue;

If I remove all new lines from the XML and keep it as one long line, it works the same in both browsers. Maybe the RSS Reader problem is related to this.

Possible solution: Using attributes instead of sub-nodes might alleviate this (and it also takes fewer characters). For example:

<coordinates>
  <coordinate id="FISM" 
   name="The Franklin Institute Science Museum" 
   latitude="39.9580" longitude="-75.1732" />
</coordinates>

Comment: I am not seeing this behavior. I am able to parse the XML the same in IE and Firefox. Maybe there is a strange carriage return or something in your XML.

Possible solution: If this is an XML document you're creating yourself, the problem might be in the doctype or <?xml ?> tag declaration. See here. Relevant quote: "Usually without DTD or XML schema definition, all whitespaces are significant whitespaces and should be preserved. However, with DTD or XML schema definitions, only the whitespaces in the content are significant as follows:"...

Possible solution: Rather than using firstChild and childNodes to get the node you want, try using XPath expressions. The cross-platform zXML library mentioned in the Ajax book lets you do it pretty easily. Then you can forget about the extra nodes and you'll have a bit more freedom to change your XML without breaking your program.


Problem: What is the status of the web service's failure to work in IE? I have read the original problem statement below and the responses, but I am confused. When I try to use my getFeedPost.htm page in IE (or Pat's), it doesn't work. Should we still be concerned with having our rss reader work in IE?

Comment: If getFeedPost.htm is not working in IE, it is (likely) not working at all, most likely because of an incorrect URL in the Ajax call (unless you have changed something else). It is still a requirement that the RSS Reader itself should work in both IE and Firefox. [Pat]


Problem: On the Ruby Software page, someone posted that the SciTE editor is available for Mac, but the provided link is unhelpful. Anyone know where to get this? [Dave]

Possible Solution: SciTE for Mac OS X 10.3 from ConTEXT hacks

"Here is a quick port of the SciTE text editor to X11 on Mac OS X 10.3. It requires Apple's X11 library, and was built on Mac OS X 10.3.3. It is presented without warranty or support of any kind. "

Problem: RSSService webserive provided for the Ajax Assignment. It works fine with Firefox, but not with any version of IE. Due to which, the RSSReader website works only for Firefox and not with IE.

  • The issue is merely that one cannot test the web service in IE. The web service is not required to be callable from IE. Only the Ajax RSS Reader must be able to execute in IE; the call to the web service is not occurring by means of IE, but through Ajax. Hence, the above issue is not a going to prevent anyone from doing the assignment (although it is annoying). [Pat Palmer]

Possible solution: If the problem is that you're unable to call the XMLHTTPRequest object's responseXML in IE, even though it works just fine in every other browser, it looks like the problem is that IE won't parse SOAP 1.2 responses as XML because the Content-Type returned by the server is "application/soap+xml". It seems as though IE will only parse it if the Content-type is "text/xml" even though "application/soap+xml" is xml. (Someone should write to Microsoft to tell them about how their own SOAP protocol works.) A fix that worked for me was to test to see if the call to request.requestXML was successful. If not, call request.responseXML.load(request.responseBody), to tell IE that the response from the server really is XML, and to try to parse it (and then, of course, if that was unsuccessful, the XML returned from the server really was screwed up and we should take some other corrective action), i.e., something like:

    var request;   // the XMLHTTPRequest object

    ...

    if (request.responseXML.getElementsByTagName(whatever) returns a failure)
    {
        request.responseXML.load(request.responseBody)
        ...
    }

Comment: Please explain "returns a failure" further. The following code (and several variations) did not work for me:

    var request;
    var options = request.responseXML.getElementsByTagName(whatever);
    if (options[0] == null) {
        alert("null");
        request.responseXML.load(request.responseBody)
        ...
    }

The strange thing was that the alert happened, but IE was still not satisfied. Checking the browser with if (navigator.appName == "Microsoft Internet Explorer") worked for me, but didn't feel good.

Response: I meant something along the lines of:

   /* search for whatever */
   var tags=request.responseXML.getElementsByTagName(someTagName);

   /* if you didn't find anything */ 
   if (tags.length==0) {
        /* try coaxing IE to load the response as XML */
        request.responseXML.load(myRequest.responseBody);

        /* search again */
        tags=request.responseXML.getElementsByTagName(someTagName);
        if (tags.length==0) {
          /* if that didn't work, you're in trouble */
        }
   }

Comment: I believe I did point this out in class, but I'll say it again. I was not able to parse XML correctly in both IE and Firefox using the Javascript XML parser, and thus, I had to use string handling to parse the XML so that I got the answer correctly in either browser. This is shown in the posted examples. [Pat]


Problem: InstantRails complains about path problems.

Possible solution: Right-click on the InstantRails icon and look at Properties. Make sure there are no spaces in the path to the program. (If you have InstantRails on the desktop, your path is probably C:\Documents and Settings\Owner\Desktop).

By the way, this problem is not unique to InstantRails. Many programs that need to refer to other files have this problem.


Problem: For the AJAX 1 assignment, I have been trying to call the web handler from my code using the following URL with the GET method, but I keep getting an error message. Here is a simple URL created using the web handler that is giving me weird errors.

http://harbormist.com/webservice/rsslookup/XslHandler.ashx?FeedUrl=http://rss.cnn.com/rss/cnn_world.rss

Possible solution: I implemented the call to the XSL Handler with a POST, and it worked for me.

Comment: I wonder if the GET URL may be failing because the parameter string may have characters ("entities") in it that need to be encoded. Also, the getFeedPost.htm file in your web service project has the POST code to make this call; all you'd need to do would be change the URL to your domain.


Pat has made a temporary archive of this page at Problems1.

Edit - History - Print - Recent Changes - Search
Page last modified on August 07, 2007, at 02:41 PM