Its all about Ruby On Rails
Posts tagged Tips
Edge Rails: Time#current
Jul 5th
Returns Time.zone.now when config.time_zone is set, otherwise just returns Time.now
Edge Rails: Array#random_element
May 24th
Array#rand is deprecated in favor of Array#random_element and will be removed in Rails 3.
As per the comment added to the commit:
Array#rand is deprecated because it masks Kernel#rand within the Array class itself, which may be used by a 3rd party library extending Array in turn. See https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4555
Download recursive directories with wget using Username & Password for FTP
Apr 26th
Using ftp to download multiple files using ‘mget’ command is pretty common, however it downloads files from current directory only. But if you need to download recursive directories with all its content then? And specially when you don’t have shell access to the remote machine and you don’t have access to archive the targeted folder?
In such situation you can use ‘wget’ to download all recursive directories by providing your ftp details. For example:
wget -rc --user='ftpusername' --password='ftppassword' ftp://domain.com/directory_path/
uninitialized constant ActionMailer::Quoting::Encoding
Apr 13th
Just a quick note, If you are getting “uninitialized constant ActionMailer::Quoting::Encoding” while using ActionMailer, then make sure that your mailer look like:
class Notifier < ActionMailer::Base
def signup_notification(recipient)
recipients recipient.email_address_with_name
bcc ["bcc@example.com"]
from "system@example.com"
subject "New account information"
body :account => recipient
end
end
Actually, yesterday we were getting “uninitialized constant ActionMailer::Quoting::Encoding” while using ActionMailer in production but it was working fine in all modes(development/production) on localhost. Our mailer was like:
class Notifier < ActionMailer::Base
def signup_notification(recipient)
@recipients = recipient.email_address_with_name
@bcc = ["bcc@example.com"]
@from = "system@example.com"
@subject = "New account information"
@body = :account => recipient
end
end
We could not find the actual issue with this mailer. But the above said error was disappeared when we changed the same mailer as following:
class Notifier < ActionMailer::Base
def signup_notification(recipient)
recipients recipient.email_address_with_name
bcc ["bcc@example.com"]
from "system@example.com"
subject "New account information"
body :account => recipient
end
end
Do you guys have any idea? I would love to listen from you.
Update: No its not solved yet. Still same issue. May be some issue with character encoding with the TMail object.
Update 2: This was the issue http://github.com/hmcgowan/roo/issues#issue/4/comment/106328
Jquery Full Calendar with RubyOnRails
Mar 29th
Cross Posted from http://vinsol.com/blog
Contrary to popular belief, working on a client project gives us a generous margin of creativity and explore innovative solutions.Take the example of a recent project I was working on. The client required a collaboration-based calendar module for their application similar to Google Calendar. Initially we started developing it from scratch , but then, we found an awesome Jquery plugin.
“FullCalendar” provides a full-sized, drag & drop calendar. It uses AJAX to fetch events on-the-fly for each month. It also supports an intuitive interface to manage events that spans over multiple days or weeks. It is visually customizable and exposes hooks for user-triggered events (like clicking or dragging an event).
I decided to give it a try and utilize its hooks for user triggered events within our Rails application. This small effort resulted in a barebone Rails app that might provide a good base for your project which require calendar, scheduling or appointment features. I called it fullcalendar_rails and it is now available on github with a working demo at http://fullcalendar.vinsol.com.
Update: Added recurring events functionality to the demo app.
Feel free to give your valuable feedback. I hope you will find this useful.