Hi,
I’m pretty new to Ruby on Rails and web development in general. I have
a question and was wondering if anyone could help me out.
Right now I have some .jar files that are embedded in a web page
ala…
<Applet code="something.class"
archive="pluginLib-jre1.6.0_05.jar,some.jar,another.jar"
width="1200" height="480" MAYSCRIPT=true >
…yadda yadda yadda…
</Applet>
These work fine in a normal html page (locally, no webserver
required). When i attempt to embed them within a rails page it cannot
seem to find the path to the .jar files. I exported the Dir::pwd and i
checked out Rails ENV and started copying the jar files everywhere but
it still never seemed to find it it… am I missing something?
Is there something special i have to do to get rails to recognize
this? what is my loadpath/where should i be putting these .jar files?
Thanks for the help
Hi,
You will either need to put them in a folder (or directly in) the
public folder OR create a controller that can serve the files out
using a send_file method might also work but in general files you want
to provide go under the public folder (eg. images in public/images).
Once a file is in public the relative path would be /file_name or if
it is in a sub-folder (eg. images) /images/file_name.
I think that covers the basics…
Paul Crawford
Also, there is the RAILS_ROOT variable that helps you find your way from
the
rails root directory no matter where the project is.
Thanks, i’ll give that a try
I have similar problems. Instead of a straightforward class file, I
have the class file in packages, e.g.
<applet code=“org.abc.something.class”
archive=“def.jar”
width=“1200” height=“480”… >
…
Although I have the def.jar file in RAILS_ROOT/public directory, rails
complains that it can’t load the class file. It says:
ActionController::RoutingError (no route found to match “//
org/abc/something.class” with {:method=>:get}):
Please help. Thanks in advance.
I found one non-rails but simple workaround.
I setup an apache server and put the java applet in an accessible
folder, e.g. http://localhost/public. Then in the applet tag, I
inserted the attribute codebase. e.g.
<applet codebase=“http://localhost/public”
code=“org.abc.something.class”
archive=“def.jar”
width=“1200” height=“480”… >
…
phew…
However, if there is still a simple way to load an applet from within
rails I would be very interested to find out as well.