RailsCasts Pro episodes are now free!

Learn more or hide this

Pablo Cantero's Profile

GitHub User: phstc

Site: http://pablocantero.com

Comments by Pablo Cantero

Avatar

I do like Form Objects, but all examples of it forget the edit action, which increases the complexity of the Form Object and decreases its beauty.

Avatar

Don't forget to wrap up the save! in a transaction.

  ActiveRecord::Base.transaction do
    user.save!
    profile.save!
  end

If something went wrong in the profile.save! the user must be rolledback.

I do like Form Objects, but all examples of it forget the edit action, which increases the complexity of the Form Object and decreases its beauty.

Avatar

Hey!

Following the activemodel source code, the initialize method should check if the attributes isn't nil.

def initialize(attributes={})
  attributes.each do |name, value|
    self.public_send("#{name}=", value)
  end if attributes
end

Without it, I got errors running my specs

 NoMethodError:
   undefined method `each' for nil:NilClass
Avatar

Unfortunately if the app uses one dyno 24x7, the app cannot use the free quota for the worker as well. :/

Avatar

Hey Nuno, I created a tool to help people to test HTML e-mails.

The tool, called Puts Mail uses Premailer to check HTML warnings and to make the CSS inline. ;)

But I think that your concern is more about the screencast Sending HTML Email, no?

Cheers,
Pablo Cantero

Avatar

How does the distance_from work? Is the distance considering the streets, the same as used on maps.google.com (by walk, by car, by bus and etc) or just straight point to point?

Avatar

One suggest is to add user and password as env variable

    $ export GMAIL_USER=email@email.com
    $ export GMAIL_PASSWORD=password
    $ export MY_DOMAIN=pablocantero.com

    ActionMailer::Base.smtp_settings = {
      :address => 'smtp.gmail.com',
      :port => 587,
      :domain => ENV['MY_DOMAIN'],
      :user_name => ENV['GMAIL_USER'],
      :password => ENV['GMAIL_PASSWORD'],
      :authentication => 'plain',
      :enable_starttls_auto => true
    }

If you are using heroku

    $ heroku config:add GMAIL_USER=email@email.com
    $ heroku config:add GMAIL_PASSWORD=password
    $ heroku config:add MY_DOMAIN=pablocantero.com

Avatar

Thanks for the share! It's a very useful post. I already used it.

I created a post based on this post, to demonstrate a sample Rakefile to use with this Railscast

http://pablocantero.com/blog/2011/01/02/new-gem-with-bundler-sample-rakefile/

Rakefile
https://gist.github.com/762965