James' Blog

James’ personal blog

You are currently browsing the archives for December, 2009.

Using JQuery + Prototype in Rails

Original info was found here.  It was posted about 3 years ago, so JQuery has changed a little since then with the implementation of JQuery.noconflict().

In a nutshell, just in clude JQuery first and then include the other libraries(s) that may use the $( function. Make sure you call JQuery stuff with JQuery(xxx) instead of $( from now on.  You include JQuery in rails usually in your main layout file by typing:

<%= javascript_include_tag ‘jquery’ %>

Make sure the jquery download files are in your /public/javascript directory of your project.

The JQuery site suggested adding the noconflict at the end of the jquery.js file, but instead I did it this way in the layout file.

<script>jQuery.noConflict(); </script>

Posted 9 months ago at 2:10 pm.

Add a comment

change validation error names in rails

Put the below code in to your model.  I found this info on railsforums.com.

HUMANIZED_COLUMNS = {
:Column_name => “New Name”,
:OtherColumn_name => “New Name 2″
}
def self.human_attribute_name(attribute)
HUMANIZED_COLUMNS[attribute.to_sym] || super
end

Posted 9 months ago at 2:01 pm.

Add a comment