Winn.ws

Rails Plugin: WinnScriptatype

Making an Ajax checkbox just got easy. This very simple plugin was built for my own use. The idea was to make one call for my checkbox, update to the database, and an effect. This plugin is easy to use and install, i dont have it setup in an svn yet so you will need to download it and place it in RAILS_ROOT/vendor/plugins/HERE.

I had been working on this plugin for a few weeks in making a new application. I kept writing the “input, Ajax.Request and, Effect.Fade”, so i needed a way to make that fast and do what i need. And out came this handy plugin!

[ruby]
# Lets use this new plugin
checkbox_do_fade(‘theDiv’, ‘CheckboxID’, {:controller => ‘todo’, :action => ‘finish’, :id => todo.id}, {:userid => user.id})

[/ruby]

Here is an over view of the options:

[ruby]
checkbox_do_fade(‘*’, ‘**’, {***}, {****})

[Element ID]* This is the name of the element you want to effect such as a div or table (tr,td)…

[Checkbox ID]** This is the id of the checkbox it self

[URL/path]*** this is the url for the update to take place NOTE: always use controller,
action, and id DO NOT place other variables in this block that is for the next block.

[URL/path options]**** This block is used for url options like so: (/path/to/1?userid=1) as you see
userid is 1, this is done by using the url options block. You may send an unlimited number of
url options with this.

# Below are the ONLY supported calls
checkbox_do_fade # This will fade the element
checkbox_do_puff # This will puff the element
checkbox_do_blindup # and so on…
checkbox_do_dropout # again…
[/ruby]

Ready to start using it? Download WinnScriptatype

You will also need help installing this plugin so take a look at Ruby on Rails Railway : WinnScriptatype.

posted in: Development, WinnScriptatype 03.26.08

Magic Multi-Connections

This plug-in is a great one! I have found a few bugs but it did the job just as i needed it to. I am using this plug-in to connect to three databases, where i am selecting, updating, inserting, and deleting. By adding this plug-in i was able to set my databases in the database.yml file and name them as i wanted. Next i adding two modules to my environment.rb file. After that i was able to connect to each of the databases with ease.

Below is how my database.yml file looks:

[ruby]
databaseone:
adapter: mysql
database: one
username: root
password:
host: localhost

databasetwo:
adapter: mysql
database: two
username: root
password:
host: localhost

production:
adapter: mysql
database: three
username: root
password:
host: localhost
[/ruby]

Now in my environment.rb file i have:

[ruby]
module Dbone
establish_connection :databaseone
end
module Dbtwo
establish_connection :databasetwo
end
[/ruby]

Now if i would like to select from my database one i do the following in any controller:

[ruby]
def index
@users = Dbone::Users.find(:all)
end
[/ruby]

Get the idea now? It’s the same to update and add to the database. Just use the module name. Now for the “production” database everything remains the same, no need to add a module to it.

Get Magic Multi-Connections V1

posted in: Development 03.25.08