01.25
Ruby on Rails: ActiveRecord to_xml – for REST API use
By Satish Natarajan
If you are going to use REST API in any fashion. You got to read this documentation
http://api.rubyonrails.org/classes/ActiveRecord/XmlSerialization.html
Findings, Tips & Tricks
If you are going to use REST API in any fashion. You got to read this documentation
http://api.rubyonrails.org/classes/ActiveRecord/XmlSerialization.html
Please refer to this link: http://nubyonrails.com/articles/memcached-basics-for-rails
Will add sample shortly
Yes, That is it!
c = a | b
Union function
Rails 1.2 supports Enumerable module on arrays. Here is the complete documentation: http://api.rubyonrails.org/classes/Enumerable.html. I found it very useful in say calculating sum of all the values within an array of records.
eg:
invoices = Invoice.find(:all, :conditions => “due_date < CURRENT_DATE”)
total = invoices.sum(&:amount) – VERY NICE!
I looked at various lightboxes and figured out this one works the best.
http://code.google.com/p/rb-lightbox-plugin/
There is no explicit documentation – However look at the lib/lightbox-helper code for all that you needs.
The one that I like the best is the ability to do
<%= link_to_remote_lightbox “LINK NAME”, :url => link_path -%>
this loads the content within the lightbox using an ajax call dynamically.
Best results if you can create a specific layout say “Modal”
<div class=”modal”>
<div style=”float:right”><%= link_to_close_lightbox image_tag(”lightbox_close.gif”, :border=> 0)%></div>
<%= yield %>
</div>
Make sure to use this in your controller
respond_to do |wants|
wants.html
wants.js {render :layout => “modal”}
end
If you need more explanation – Please leave a comment – I will add additional documentation to this post.
BTW, I had to copy the javascript, images and stylesheets to the appropriate directory manually – was not too hard.
Also, you might have to svn checkout into the plugins directory – the script/plugin install did not work for me.
It is worth the effort.
If you want to quickly see your data using scaffolding, then ActiveScaffold is your friend.
Visit ActiveScaffold here: http://activescaffold.com/
You will find it useful in writing the administration portions of the website. There are quite a bit of customizations for the creative designer!
Ruby on rails remove the underline from the link
link_to(model.name, model_path(model),:style => “text-decoration: none”)
This is a good plugin to use for lightboxes.
http://www.craigambrose.com/projects/redbox
Install: script/plugin install svn://rubyforge.org/var/svn/ambroseplugins/redbox
Initialize: cd vendor/plugins/redbox; rake update_scripts
(gave me an error) so I did
cp javascripts/* ../../../public/
cp images/* ../../../public/images/.
cp images/* ../../../public/images/.
Location with some good examples: http://richtextblog.blogspot.com/2007/09/redbox-rules.html
Simple
sudo yum install php-mbstring
This is an excellent article.