ruby – WebOnRails http://webonrails.com Mon, 18 Jan 2016 10:25:01 +0000 en-US hourly 1 #/?v=4.4.13 uninitialized constant ActionMailer::Quoting::Encoding /2010/04/13/uninitialized-constant-actionmailer-quoting-encoding/ /2010/04/13/uninitialized-constant-actionmailer-quoting-encoding/#comments Tue, 13 Apr 2010 16:25:25 +0000 /?p=370 Continue reading uninitialized constant ActionMailer::Quoting::Encoding]]> 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        ["[email protected]"]
     from       "[email protected]"
     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            = ["[email protected]"]
     @from          = "[email protected]"
     @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        ["[email protected]"]
     from       "[email protected]"
     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

]]>
/2010/04/13/uninitialized-constant-actionmailer-quoting-encoding/feed/ 1
Multiple versions of ruby on ubuntu /2009/06/23/multiple-versions-of-ruby-on-ubuntu/ /2009/06/23/multiple-versions-of-ruby-on-ubuntu/#comments Tue, 23 Jun 2009 15:33:26 +0000 /?p=300 Three-Four days ago I was in a situation where I need to have multiple versions of ruby and rubygems on my ubuntu machine. I was lucky, I found an awesome article http://blog.michaelgreenly.com/2008/08/multiple-versions-of-ruby-on-ubuntu-2.html. This really solved my problem, Many thanks to Michael Greenly.

]]>
/2009/06/23/multiple-versions-of-ruby-on-ubuntu/feed/ 2
Taskit: Another task scheduler for rails /2009/05/21/taskit-another-task-scheduler-for-rails/ /2009/05/21/taskit-another-task-scheduler-for-rails/#respond Thu, 21 May 2009 06:32:15 +0000 /?p=298 While searching something I found and interesting plugin ‘Taskit‘, which I want to test for sure in production/staging when ever I get the chance.

Anybody tried it already?

]]>
/2009/05/21/taskit-another-task-scheduler-for-rails/feed/ 0
Printing large image diagrams generated by RailRoad /2009/03/23/printing-large-image-diagrams-generated-by-railroad/ /2009/03/23/printing-large-image-diagrams-generated-by-railroad/#respond Mon, 23 Mar 2009 10:24:05 +0000 /?p=268 Continue reading Printing large image diagrams generated by RailRoad]]> I use RailRoad for generating Ruby on Rails diagrams, but always wish I could print those diagrams. Generally diagrams are too big to print on a single A4 size paper and I didn’t find any tool to print larger images in parts so that I can join them. If I print the image generated by RailRoad on single page, it of no use as it is hardly readable.

Fortunately, two days ago I found something which resolved this issue. It is a linux command and print a particular image on four pages. Here is that command:

lp -o scaling=200 models.png

]]>
/2009/03/23/printing-large-image-diagrams-generated-by-railroad/feed/ 0
Hassle free installation of rails stack on debian based system /2009/02/23/hassle-free-installation-of-rails-stack-on-debian-based-system/ /2009/02/23/hassle-free-installation-of-rails-stack-on-debian-based-system/#comments Mon, 23 Feb 2009 16:34:52 +0000 /?p=255 Continue reading Hassle free installation of rails stack on debian based system]]> Want to install rails stack on a machine? Just follow these steps. It will setup a rails stack(Apache + passenger + mysql + ruby + rubygems + common gems + git) on any server(debian based)

  1. apt-get update
  2. apt-get upgrade -y
  3. apt-get -y install build-essential libssl-dev libreadline5-dev zlib1g-dev
  4. apt-get -y install mysql-server libmysqlclient15-dev mysql-client
  5. apt-get -y install ruby ruby1.8-dev irb ri rdoc libopenssl-ruby1.8
  6. install rubygems manually:
    1. download rubygems form rubyforge, >=1.3
    2. unzip files
    3. ruby setup.rb
    4. Check that gem command is in path. Sometimes ‘gem1.8’ is available but ‘gem’ not. In that case copy /usr/bin/gem1.8 to /usr/bin/gem using “cp /usr/bin/gem1.8 /usr/bin/gem”
  7. apt-get -y install libmagick9-dev
  8. apt-get -y install imagemagick
  9. apt-get -y install postfix mailx
  10. apt-get -y install apache2
  11. apt-get -y install apache2-prefork-dev
  12. wget /wp-content/plugins/download-monitor/download.php?id=7
  13. ruby install_gems.txt
  14. passenger-install-apache2-module
  15. Download git from git-scm.com

    1. Unzip files
    2. ./configure –without-tcltk
    3. make -j 2
    4. make install

You are all set now, go deploy you rails app. I have tested it on linode(ubuntu8.10), slicehost(ubuntu 8.10), should work for you too

]]>
/2009/02/23/hassle-free-installation-of-rails-stack-on-debian-based-system/feed/ 5
Edge rails: ActiveRecord::Base.each and ActiveRecord::Base.find_in_batches for batch processing /2009/02/23/edge-rails-activerecordbaseeach-and-activerecordbasefind_in_batches-for-batch-processing/ /2009/02/23/edge-rails-activerecordbaseeach-and-activerecordbasefind_in_batches-for-batch-processing/#comments Mon, 23 Feb 2009 15:45:25 +0000 /?p=251 Continue reading Edge rails: ActiveRecord::Base.each and ActiveRecord::Base.find_in_batches for batch processing]]> You guys must faced a situation when you need to process large number of records, for example sending newsletters. Then you must have done some sort of batch processing to save it eating up all of your memory. This feature is committed to rails core by DHH.

Now you can do something like User.each and User.find_in_batches.

Please refer here for more details.

]]>
/2009/02/23/edge-rails-activerecordbaseeach-and-activerecordbasefind_in_batches-for-batch-processing/feed/ 8
rake -T does not list my custom rake task /2009/02/13/rake-t-does-not-list-my-custom-rake-task/ /2009/02/13/rake-t-does-not-list-my-custom-rake-task/#comments Fri, 13 Feb 2009 15:35:04 +0000 /?p=230 Continue reading rake -T does not list my custom rake task]]> This is just a tip, may be you guys are already aware of it.

Sometimes I wonder why my custom rake task doesn’t appear in rake -T list, however it runs well. I just noticed that if I do not specify description for a task then that particular rake task does not appear in the task list.

]]>
/2009/02/13/rake-t-does-not-list-my-custom-rake-task/feed/ 3
Tip: Open DB shell/console from rails root dir /2009/01/29/tip-open-db-shellconsole-from-rails-root-dir/ /2009/01/29/tip-open-db-shellconsole-from-rails-root-dir/#respond Thu, 29 Jan 2009 15:17:14 +0000 /?p=205 Continue reading Tip: Open DB shell/console from rails root dir]]> Just a quick tip you might be using this already.

If you guys want to open your app’s DB shell. Then you can use rails utility ‘dbconsole’ by issuing “script/dbconsole” from rails root directory.

It will ask for DB password, and open your db shell.

If you use sake, you may like following sake task:

desc ‘Launches the database shell using the values defined in config/database.yml’
task ‘db:shell’, :needs => [ ‘environment’ ] do
config = ActiveRecord::Base.configurations[(RAILS_ENV or “development”)]
command = “”
case config[“adapter”]
when “mysql” then
(command << "mysql ") (command << "--host=#{(config["host"] or "localhost")} ") (command << "--port=#{(config["port"] or 3306)} ") (command << "--user=#{(config["username"] or "root")} ") (command << "--password=#{(config["password"] or "")} ") (command << config["database"]) when "postgresql" then puts("You should consider switching to MySQL or get off your butt and submit a patch") else (command << "echo Unsupported database adapter: #{config["adapter"]}") end system(command) end [/ruby]

]]>
/2009/01/29/tip-open-db-shellconsole-from-rails-root-dir/feed/ 0
quick_scopes: Rails plugin to automatically add some quick named_scopes to your models /2009/01/29/quick_scopes-rails-plugin-to-automatically-add-some-quick-named_scopes-to-your-models/ /2009/01/29/quick_scopes-rails-plugin-to-automatically-add-some-quick-named_scopes-to-your-models/#respond Thu, 29 Jan 2009 14:50:41 +0000 /?p=208 Today I came across a new plugin named quick_scopes, and thought you guys might be interested to give it a try. Checkout http://github.com/internuity/quick_scopes/tree/master

]]>
/2009/01/29/quick_scopes-rails-plugin-to-automatically-add-some-quick-named_scopes-to-your-models/feed/ 0
ActionMailer Error: hostname was not match with the server certificate /2009/01/28/actionmailer-error-hostname-was-not-match-with-the-server-certificate/ /2009/01/28/actionmailer-error-hostname-was-not-match-with-the-server-certificate/#comments Wed, 28 Jan 2009 07:50:03 +0000 /?p=198 Continue reading ActionMailer Error: hostname was not match with the server certificate]]> You guys may have stuck with following error while using ActionMailer with Rails 2.2.2 .

OpenSSL::SSL::SSLError (hostname was not match with the server certificate):
    /usr/lib/ruby/1.8/openssl/ssl.rb:123:in `post_connection_check'
    /usr/lib/ruby/1.8/net/smtp.rb:582:in `tlsconnect'
    /usr/lib/ruby/1.8/net/smtp.rb:562:in `do_start'
    /usr/lib/ruby/1.8/net/smtp.rb:525:in `start'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:671:in `perform_delivery_smtp'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:526:in `__send__'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:526:in `deliver!'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:392:in `method_missing'
    /app/controllers/users_controller.rb:40:in `send_email_to_confirm_user'

Actually, Rails 2.2.2 turn on STARTTLS if it is available in Net::SMTP (added in Ruby 1.8.7) and the SMTP server supports it.

If you use postfix, then you fix it quickly by disabling tls by setting “smtpd_use_tls=no” in /etc/postfix/main.cf .

Remember to restart postfix and rails app server.

]]>
/2009/01/28/actionmailer-error-hostname-was-not-match-with-the-server-certificate/feed/ 11