DON'T USE "DISABLE WITH TEXT" OPTION WITH YOUR JQUERY AJAX BINDING no comments

Posted by stephane Mon, 10 Aug 2009 07:22:00 GMT

I ve just spent 5 hours to understand what was going wrong with my ajaxy form. I use jquery on rails and ajaxForm plugin, I have some form already working good and tried to a new one.

But this time it doesnt work, I dont understand why my form send twice the request, first with ajax header and second time with html request. I even tried to write raw javascrit, livequery and so on. Nothing make it works. Finally I want to check a little thing I add on the form: ‘disable with text’ option. I disabled it and miracle it works now.

I ve lost 5 hour of my time for this little cosmetic tool that s mess up ajax binding.

Then my advice: DON’T USE “DISABLE WITH TEXTOPTION WITH YOUR JQUERY AJAX BINDING.

How to access multiple databases with rails 5 comments

Posted by stephane Sat, 31 May 2008 17:08:00 GMT

I know it exists other information about this, but I want to summarize here the practise I use in several project now. It takes 4 steps:

  • configure your database.yml
  • create an abstract class for connection
  • create new models within a module
  • interact the 2 databases

1. Configure your database.yml

This is the same as you create production or development connection, just give it a specific name:

other_database_connection:
    adapter: postgresql
    encoding: utf8
    database: database_name
    username: user
    password: password
    host: localhost

2. Create an abstract class for connection

Then create an abstract class you will inheritate by your new classes:

class External < ActiveRecord::Base
  self.abstract_class = true
  establish_connection :other_database_connection
end

3. Create new models within a module

To make it easier to use and cleaner, create a subfolder OtherDatabase and then create in this folder your new classes (for each table you need) as following:

class OtherDatabase::NewClass1 < External
end

4. How to interact the 2 databases

Once you have created your new classes, you can simply access it using the module prefix:

new_object = OtherDatabase::NewClass1.new
.
result = OtherDatabase::NewClass1.find(:all)

Conclusion

That’s all, submodule is not really necessary but keeps your model folder cleaner. Any suggestion to improve this practise ?

Rails: find controller for a path no comments

Posted by stephane Sun, 06 Apr 2008 12:20:00 GMT

Huh, seems simple to do :p, but I’ve been seeking for a while to find the answer and dig into rails code to find a simple method to retrieve the controller of a given path (could be useful to build a navigation). There it is:

ActionController::Routing::Routes.recognize_path(path)[:controller]

Ebb, even faster than Thin no comments

Posted by stephane Tue, 04 Mar 2008 21:02:00 GMT

Ebb is new server to put in front of a rackable ruby application.

Have a look to the Ebb website to get some comparison with other app servers.

sudo gem install ebb

What I needed to do before on Mac OS X (leopard with MacPorts):

sudo port install glib2

Older posts: 1 2 3 ... 12