Rails Email Preview

Just a short post for myself to remember the ActionMailer Preview functionality.

test/mailers/previews/mailer_preview.rb

class MailerPreview < ActionMailer::Preview
  def mailer_method_name
    TeamPersonMailer.mailer_method_name( email_method_argument ) 
  end
end

And view your preview emails at: http://localhost:3000/rails/mailers

share!

Opinion: Magento Hell !

Overriding a class in Magento. The nice way to do it is to define your own module and override the class. (2 xml files, 1 source file. distributed over the source tree :S )

<?xml version="1.0"?>
<config>
	<modules>
   		<Company_Shipping>
			<active>true</active>
			<codepool>local</codepool>
  		</Company_Shipping>
	</modules>
 </config>

This didn’t work. No errors, no message just didn’t activate my module.
This did work. Find the differences:

<?xml version="1.0"?>
<config>
	<modules>
   		<Company_Shipping>
			<active>true</active>
			<codePool>local</codePool>
  		</Company_Shipping>
	</modules>
 </config>

(Check the word codepool instead of codePool)

Every time I’m working with Magento I get these kind of problems and issues. It takes to much time to make simple changes. Way to much configuration. No descent error messages. Files littered across multiple folders.

:S

Makes me glad I can work with Spree (and Rails) most of the time. With nice convention based overrides. Gem support. Nice deployment. Git friendly etc. ;)

Incompatible Rails Local Configuration

Today I experienced a problem when upgrading to rails 4.2 from rails 3.

When updating an Activerecord object with a DateTime value, I’ve got the following error:

NoMethodError: undefined method `getlocal' for Mon, 01 Jan -4712 00:00:00 +0000:DateTime

I had the following configuration in my Application object:

  config.active_record.default_timezone = :local  # store all values in the local time-zone 
  config.active_record.time_zone_aware_attributes = false # ignore the time zone

I don’t want time-zone information for this project.
But getting an error isn’t nice so I solved it by enabling the time_zone_aware_attributes.

  config.active_record.default_timezone = :local  # store all values in the local time-zone 
  config.active_record.time_zone_aware_attributes = true # ignore the time zone

RVM / Ruby Certificate Issues on FreeBSD

Today I was trying to deploy my updated rails application via capistrano
Suddenly I’ve got the following message

ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

Trying to update the gem system manually had the same problem:

[root@w1 ~]# gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

Setting the environment variable ‘SSL_CERT_FILE’ to the location of the root-certificates from the ports collect ion resolved the issue:

[root@w1 ~]# SSL_CERT_FILE=/usr/local/etc/ssl/cert.pem  gem update --system
Updating rubygems-update
Fetching: rubygems-update-2.4.5.gem (100%)
Successfully installed rubygems-update-2.4.5

Now I’ve reinstalled the port security/ca_root_nss and enabled the ETCSYMLINK option. This resolved my issue. Now my system uses the latest root-certificates. (*duh*)

Just a note, had another rails project, that didn’t work out of the box. Fixed this by adjusting the deploy.rb script. I’ve added the following:

set :default_env, { 
  SSL_CERT_FILE: '/etc/ssl/cert.pem'
}

Dragon Head Sketch

Today I had a drawing afternoon with the kids. To things a bit different this time,
we searched for a nice tutorial from Marc Crilley on the internet.

And my result of the tutorial was the following drawing. Not perfect, but nice enough to place on my Blog.. (Great tutorial btw, !)

dragon-20141008-smaller

You can find the tutorial here: https://www.youtube.com/watch?v=ZScXLoFHShQ

I’m sure I’m going to watch more of Marc Crilley !!