RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: phstc
Site: http://pablocantero.com
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.
Don't forget to wrap up the save! in a transaction.
save!
ActiveRecord::Base.transaction do user.save! profile.save! end
If something went wrong in the profile.save! the user must be rolledback.
profile.save!
user
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
Unfortunately if the app uses one dyno 24x7, the app cannot use the free quota for the worker as well. :/
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
I think that it's straight point to point...
http://rdoc.info/github/alexreisner/geocoder/master/Geocoder/Calculations#distance_between-instance_method
http://en.wikipedia.org/wiki/Haversine_formula
You may try VCR to stub the HTTP response.
http://github.com/myronmarston/vcr
;)
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?
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
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
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.
Don't forget to wrap up the
save!
in a transaction.If something went wrong in the
profile.save!
theuser
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.
Hey!
Following the activemodel source code, the initialize method should check if the attributes isn't nil.
Without it, I got errors running my specs
Unfortunately if the app uses one dyno 24x7, the app cannot use the free quota for the worker as well. :/
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
I think that it's straight point to point...
http://rdoc.info/github/alexreisner/geocoder/master/Geocoder/Calculations#distance_between-instance_method
http://en.wikipedia.org/wiki/Haversine_formula
You may try VCR to stub the HTTP response.
http://github.com/myronmarston/vcr
;)
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?
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
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