botvector.net domain for sale $2k usd (negotiable). Em@il me t0: alex DOT creopolis at gmail DOT com

My Git activity

28 August 2008

will_paginate on AJAX

Do you want will_paginate with AJAX functionality ?
Follow:

  1. Remove will_paginate plugin if you have it (/vendor/plugins/) /or backup it.
  2. in command line: gem sources -a http://gems.github.com
  3. in command line: gem install mislav-will_paginate
Now in config/environment.rb put after Initializer
Rails::Initializer.run do |config|
...
end

require 'will_paginate'
Next step, create new helper: remote_link_renderer.rb .. and copy&paste inside:


class RemoteLinkRenderer < WillPaginate::LinkRenderer
def prepare(collection, options, template)
@remote = options.delete(:remote) || {}
super
end
protected
def page_link(page, text, attributes = {})
@template.link_to_remote(text, {:url => url_for(page), :method => :get}.merge(@remote))
#replace :method => :post if you need POST action
end
end

Now, to ajaxize put:
<%= will_paginate :collection, :renderer => "RemoteLinkRenderer",:remote => {:with => "something_you_want", :update => "dom_id_element"} %>

And you are happy-ajax-paginator !
Sample:
<%= will_paginate @events, :renderer => "RemoteLinkRenderer",:remote => {, :update => "events_container", :loading => visual_effect(:appear, "loader"),:complete =>visual_effect(:fade,"loader" ) } %>
will call /events?page=x with AJAX request..
in my EventController:

respond_to do |format|
format.html { }
format.js { render :partial => "events" }
format.xml { render :xml => @events.to_xml }
end

Thats all !!
More info about will_paginate plugin here
Original post here

13 August 2008

acts_as_taggable_on_steroids + Globalize

Okay, situation is:

Parties involved: Rails 2.0.2, Globalize plugin, acts_as_taggable_on_steroids, ME.
(clickables) :)

Having model Event that translates :name, :body, :description with Globalize plugin.
Also Event are acts_as_taggable with acts_at_taggable_on_steroids ...

Ok for now, model works well, translated well, adding/removing/editing tags as well !

The problem is raise when we trying to @tags = Event.tag_cloud
we got :select option not allowed on translatable models (DISTINCT * FROM events .... !! THAT IS BADD !!!

Solution:
Open /ventor/plugin/acts_as_tabbable_on_steroids/lib/acts_as_taggable.rb
FIND:


LINE: 66
def find_tagged_with(*args)
options = find_options_for_find_tagged_with(*args)
options.blank? ? [] : find(:all, options)
end

CHANGE TO:

def find_tagged_with(*args)
options = find_options_for_find_tagged_with(*args)
options.blank? ? [] : untranslated_find(:all, options)
end


Restart server and you're done !

p.s. More info about great acts_as_taggable_on_steroid plugin is here.

09 August 2008

Dreamhost Hosting

Hi !

Personally i am hosting 3 websites working very well with dreamhost ( thru mod_rails & passanger), and its very easily to create new projects, svn repositories, mysql, custom gem packs, etc... everything You need for Rails site.

SOO if you want fast and cheap rails hosting check Dreamhost !
I would recommend basic plan(its really enought for hosting rails!),
I can give You free LIFETIME domain registration(domain never expires and You NEVER pay for him) !
This discount give's You upon NEW registration.
Plus i give You:
10$ off for monthly hosting plan,
25$ off for one year plan,
40$ (!) off for two year plan,

So get yourself promotional code BOTVECTORCX on DREAMHOST (click here)
(free lifetime domain + hosting discounts), enter promotional code in bottom of registration form to redeem $$$$$$ !
Have Fun !!! :)


p.s. If you need more specific code let me know ;)