How do I require a partial?

I'm fairly new to Rails and am trying to figure out how to add a method to the String class and have the code in my partial know that the String class has been added to. I'm not sure where I should put the require statement.

Answers


lib/monkeypatch.rb

class String
  def some_new_func
    ...
  end
end

app/controllers/application.rb:

require "monkeypatch"

(or, if you only want the monkeypatch for a specific controller, put the require in that controller).

See also: Rails /lib modules and


Need Your Help

How do I select the innermost element?

javascript jquery html

In jQuery, how would I descend as far as possible into the HTML tree?

CSS Polaroid Style Image with Unknown Dimensions

css image dimensions

I want to create a polaroid style image using CSS. However, I'd like to square the image creating a large thumbnail so all images are the same size. I don't know the dimensions of the image beforeh...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.