Tuesday, March 31, 2009

Thursday, March 26, 2009

send_file or send_data in link_to_remote

Hi guys,

really really long time i did anything here :).. and no this time not an usual bhaana(excuse) will do but an genuine reason.. was busy building something good.. and it is a secret(just can't disclose it here like this).

Anyhow coming to point.. i was doing a general routine development task for my company and i got hit by a situation like this.. where i was making an ajax call to a controller/action and in response i was sending a stream i.e (send_data and send_file) but as the post was xmlhttp everything was working fine but download was not available (and yeh over here i coded it for download not the inline stuff). What to do now.... i searched it ya ya googled it and response was not a solution that i can rely on(it might not be google's fault must be mine, but why am i favoring it.. it must be google fault lol :)) )

So i solved it my own way by redirecting the update to other action and coding the stream in the newly redirected action :)

Here are some snippets of it....

<%=link_to_remote "Export the result",:url => {:controller => "some_controller", :action => "ask_to_export"},:with => "'record_ids=1-2-3-4-5-6'" -%>

def ask_to_export
render :update do |page|
page.redirect_to :action => "process_and_export", :record_ids => params[:record_ids]
end
end

def process_and_export
outfile = ""
CSV::Writer.generate(outfile) do |csv|
csv << ["praveen","kumar","sinha",1,2,3,nil,""]
end
send_data outfile, :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => "attachment; filename=report_#{Time.now.to_f.to_s}.csv"
end

I hope this must be helpful to some one stucked over here and googling it

Thanks :)

Sunday, March 8, 2009

NetBook ASUS EeePC

O my god!!! i got this small little machine.... the coolest gadget till yet. and have some snaps ....



Tech specs are intel Atom Duo, 2 GBytes of Ram, the ddr2 one and the sleek and so bright 10 inches screen
and only 5% keyboard is what it all sacrificed it for this look.. apart from the optical drive and now i have to do something to not to miss it :))

Earlier had one dell but due to some faults in the system
its wifi stopped working and its Ram was Half of Gb and its upgrading was costing me about Rs. 2200.00, which was a bit more than i actually expected so i went to NehruPlace and changed the system it self and got this new stylish looking baby... it will do my needs and it is quite a bit handy too so small in dimension and good enough battery life of about 5 hrs and keyboard is not bothering me too either although its right shift key is a bit awkwardly placed :)

I am looking it for some more stuff to get onboard but that will be something which i think is an ongoing process for a person like me :)

That is it of for me.. the biggie news of the week

Honda Civic & A/C problems.

Hello Friends, Got a post again on to Honda Civic (The good old favorite commuter of mine). This car has been doing great except for so...