On 4 October 2011 10:09, Richard Lung <[email protected]> wrote: > Hi guys, > > I am a newbie in developing in Ruby on Rails. > I don't understand how to include the a javascript file. > so like i.e. in general HTML I use this > <script type="text/javascript" src="js/xxx.js"></script>
You can certainly do it that way if you want to (after all, by the time it gets to the browser it is just html so anything you could do without rails you can do with rails). What error did you get when you tried it? As you have coded it the file would be expected in public/js. More conventionally they would go in public/javascripts but that is up to you. More conventionally in rails you would use javascript_include_tag to include them, it saves typing and avoids having to remember the html format. > it seems like I couldn't do this directly, so I need to put the > javascript file in the script folder. > so how do direct to the file? > also, how about a href and img src? Look at link_to and image_tag Perhaps also work through some tutorials that will introduce you to all these things. railstutorial.org is good and is free to use online. Make sure that any tutorial you use matches the rails version you are using (the first two digits anyway, eg 3.0) Colin Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

