Thanks for excellent screencast. It's mind boggling to think how long Ryan has been producing these and never missing a week. Really stunning achievement. Thanks to this screencast I'm actually now trying out zsh and it feels really nice. There are loads of powerfull features.
Although I have to say that documentation you find via google can really bog you down. So this screencast really helped.
One noticeable difference I encountered is expansion of '..' and '~'. If I'm in subdirectory and want to touch/edit file higher on directory tree I usually type something like:
touch .. (this expands the prompt into: touch ../)
zsh doesn't seem to do that kind of expansion. Also hittin after typing ~ doesn't expand ~ into johndoe/ or ~/
At this point everyone with US keyboards are probably wondering why this is such a big deal? Well with scandinavian layout '/' is achieved with SHIFT+7 which is way more painfull to do instead of with your little-finger.
Trying to google for solution but if anyone has quick fix please let me know!
In my production server, I'm using ruby foreman to run multiple processes, I just want my application to keep working, even if one of the processes down, is there any tricky way to restart the processes or even not to stop all the other processes in case one went down ? I mean in production level I want the solution to be stable enough, is that possible without Upstart ?
this was extremely awesome. now if we can do multiple fields update that would be brilliant. almost reach the same level as those javascript MVC frameworks.
+1 to Andrew's request. I would love to see (and would pay for) some good tutorials on setting up server infrastructure for Rails, including monitoring with a tool like Monit/God (without having the monitoring tool crash or leak memory), and storing passwords securely.
If I may ask how did you set up your environment variables?
I'm on rails 3.1.3 and I can't put my head around how to do that in one place for many env like you have ENV['var']
We ran into this problem and wanted to reliably use the same version of jquery we were using in our project. Our solution was to hook into the rake task: https://gist.github.com/1557071
HI Ryan, I've noticed that you have used a few environment variables in the recent episodes. Do you have any opinions on how best ways of setting them? IE - one config file vs in each environment file? Maybe this could be a short episode on how environment variables work and boot sequences?
Ok, for anyone interested, i got it working now. It cannot find the fingerprinted stylesheet in production (don't know why), so i'm setting the tag manually to point to the non-fingerprinted file.
Try pressing Ctrl-C or killing the PID. It really sucks having to kill -9 because the killer never knows if they're causing some sort of state corruption.
I recommend rescuing from StandardError and possibly Timeout::Error if you are hitting some external service. Another option is to do something like this:
begin
# ...
rescue SignalException
raise
rescue Exception => e
# as before
end
Hi Ryan, I followed all the steps which is given in http://railscasts.com/episodes/209-introducing-devise. Sign up process is woking fine. Everything is getting stored in the database. But sign_in process is not working for valid users also. It is giving invalid email or password... Please help me...
Has anyone seen a good way to automatically generate the plain text emails from the html emails?
It always seemed a bit redundant to maintain both. I imagine they wouldn't look perfect but might be good enough if the primary goal was just to improve email deliverability.
Here's my newb question. I'd like to search the a related table on multiple attributes, so in the case of comments, search on the content as well as maybe the submitter. However, I'm not sure how to do the mapping to grab two attributes and concatenate them or join them in one array.
I ran into the same issue, I resolved it by adding an ignore parameter on the tree method.
I have a Family model (for a product):
ruby
classFamily < ActiveRecord::Base
has_ancestry
defself.tree(ignore=nil)
ancestry_options(Family.scoped.arrange(:order => 'name'), ignore) { |i|
"#{'-' * i.depth}#{i.name}"
}
enddefself.ancestry_options(items, ignore)
result = []
items.map do |item, sub_items|
result << [yield(item), item.id] unless item.id == ignore
result += ancestry_options(sub_items, ignore) { |i|
"#{'-' * i.depth}#{i.name}"
}
end
result
endend
In my view partial, I use the following to render a select tag - obviously the id_to_ignore is the family_id of the family I want to exclude in my select tag:
ruby
# _product.html.erb (I use SimpleForm)
<%= f.association :family, label: t(".family"), collection: Family.tree(id_to_ignore), include_blank: false, input_html: { multiple: false } %>
Thats a very good way, except when validations fail. Then the id of the created OBJECT gets passed to the view, but when the validation fails, the same OBJECT gets deleted in the ROLLBACK process.
Then when you submit the form again, Rails can´t find the object based of the ID that gets passed on from the view...
Does anyone have a solution to this problem... Maybe some kind of after_validation callback?
The Xcode install comes with gcc which is needed for compilation. You might be able to install gcc separately and get everything working smoothly. gcc isn't listed as a dependency of rvm, but I'm pretty sure it is required to make the rubies.
One thing - do you not need to install Xcode first to allow rvm to work?
(Just for context: I'm running SnowLeopard on an older machine. I did have a working installation but naiively thought I could get away with uninstalling Xcode once I'd installed Homebrew)
On Chrome 14.0 and Firefox I am using on Ubuntu, cookies are generated even if I am not checking remember me. I see _auth_session and auth_token in the cookies browser. Both are set to expire when browser is closed. But after I closed the browser and reopened it, I am automatically signed in. Only way to sign out is to click logout.
Does anyone know what could be going on? I am using the original code.
How else would you do it? Hardcoding to .id and a fixed attribute name? record_id is the function name to call to get the id, it could be :id, but also any other function like :permalink for example. attribute needs to be flexible too, otherwise you could use this builder only for one fixed named attribute. Not very practical I guess... ;-)
We just went through the painful process of sending fancy html emails on Rails 3.1 a month ago. The CSS in our emails even have media queries so they look right on mobile devices. We used premailer-rails3, but it needed a lot of patching before it worked properly.
Good episode. Aslo is good to mention the MailView plugin ( https://github.com/37signals/mail_view ) which is really nice way to test without sending the html mails.
I wrote my own gem to do this a few weeks ago, inline_styles_mailer, but it looks like I've got a lot to learn by reading how premailer and roadie work. Thanks Ryan.
I've been working on email marketing for a while now and I have to say that Gmail is the 1st email client that I use to test my emails, but then I have to test in the painful Outlooks... because the majority of clients uses Outlook (Link).
Making emails "work" in Outlook 2007 & 2010 (Windows versions) is painful, because M$ switched the render engine from IE to Word (join your voice at Link) and the Word engine doesn't follow some web standards, so be ready for some headaches.
Important lessons:
* be careful when sending a lot of emails, your email address can get blacklisted very fast
* use several email clients to test your emails
* forget CSS positions
* use a spam tester, to test your email's spam value
* add an unsubscribe link to your email, because it's mandatory (SPAM-CAN laws)
* ...
I just wanted to share a neat way to debug remote JavaScript errors and notify Airbrake that we used in a recent project. Debugging RJS and Airbrake Integration
I really appreciate the thoroughness, like the delegation, the metaprogramming, and including the HABTM example from the other Railscast. Just became a subscriber and this cast was instantly actionable.
@Radha - I use it with RVM in my cap recipe and it works fine. You have to ensure to trust all .rvmrc though via the flag or cron will hang (on the github readme for Whenever).
@Joshua:
Q1 -
namespace :deploy do
desc "write the crontab file"
task :write_crontab, :roles => [:whatever] do
run "cd #{release_path} && sudo whenever --load-file config/anyfile.rb --write-crontab #{application}"
end
end
This should work - each role should have its own whenever file - then use a cap task based on role to deploy each crontab. Credit shared with Gordon Isnor (stackoverflow question #1008530).
+1
Thanks for excellent screencast. It's mind boggling to think how long Ryan has been producing these and never missing a week. Really stunning achievement. Thanks to this screencast I'm actually now trying out zsh and it feels really nice. There are loads of powerfull features.
Although I have to say that documentation you find via google can really bog you down. So this screencast really helped.
One noticeable difference I encountered is expansion of '..' and '~'. If I'm in subdirectory and want to touch/edit file higher on directory tree I usually type something like:
touch .. (this expands the prompt into: touch ../)
zsh doesn't seem to do that kind of expansion. Also hittin after typing ~ doesn't expand ~ into johndoe/ or ~/
At this point everyone with US keyboards are probably wondering why this is such a big deal? Well with scandinavian layout '/' is achieved with SHIFT+7 which is way more painfull to do instead of with your little-finger.
Trying to google for solution but if anyone has quick fix please let me know!
In my production server, I'm using ruby foreman to run multiple processes, I just want my application to keep working, even if one of the processes down, is there any tricky way to restart the processes or even not to stop all the other processes in case one went down ? I mean in production level I want the solution to be stable enough, is that possible without Upstart ?
Any hint/help would be highly appreciated .
Hi
Thanks for this really helped.
I would like to add Roles to the mix here. Thinking of only 3 different roles what would be the best solution?
Thanks again
In your shell:
export VAR=value
Or...
echo '\nexport VAR=value' >> ~/.bash_profile
then
source ~/.bash_profile
Thanks for the screencast! Glad to see my gem here.
One thing to note about premailer-rails3 is that it will automatically create a text version of the HTML email.
I have three queries:
1) How do I assign and get the unique Id to each text box generated dynamically?
2) How do I resolve the conflict occur between jquery of datepicker and the code <%= javascript_include_tag "application" %>
3) How can I use datepicker function in each text box as datepicker uses the unique Id of each text box.
this was extremely awesome. now if we can do multiple fields update that would be brilliant. almost reach the same level as those javascript MVC frameworks.
+1 to Andrew's request. I would love to see (and would pay for) some good tutorials on setting up server infrastructure for Rails, including monitoring with a tool like Monit/God (without having the monitoring tool crash or leak memory), and storing passwords securely.
If I may ask how did you set up your environment variables?
I'm on rails 3.1.3 and I can't put my head around how to do that in one place for many env like you have ENV['var']
Does anyone know how to use this custom form builder with
fields_for
? I've tried passing the:builder
option, but it doesn't work.We ran into this problem and wanted to reliably use the same version of jquery we were using in our project. Our solution was to hook into the rake task: https://gist.github.com/1557071
If anyone could add some notes on Windows installation, feel free.
It's been awhile since I started with Rails, and I use pik; but I'm still finding upgrading to 1.9.3 a challenge.
HI Ryan, I've noticed that you have used a few environment variables in the recent episodes. Do you have any opinions on how best ways of setting them? IE - one config file vs in each environment file? Maybe this could be a short episode on how environment variables work and boot sequences?
Thanks!
This works! Thank you!
Would it be difficult to configure the server to start with foreman rather then a script?
an update on this would be greate! :)
any tips for using this on Heroku?
Ok, for anyone interested, i got it working now. It cannot find the fingerprinted stylesheet in production (don't know why), so i'm setting the tag manually to point to the non-fingerprinted file.
You want to be careful rescuing
Exception
as it catches things like Ctrl-C and other signals. This is because For example:Try pressing Ctrl-C or killing the PID. It really sucks having to
kill -9
because the killer never knows if they're causing some sort of state corruption.I recommend rescuing from
StandardError
and possiblyTimeout::Error
if you are hitting some external service. Another option is to do something like this:Hi Ryan, I followed all the steps which is given in http://railscasts.com/episodes/209-introducing-devise. Sign up process is woking fine. Everything is getting stored in the database. But sign_in process is not working for valid users also. It is giving invalid email or password... Please help me...
Great episode, thanks!
Has anyone seen a good way to automatically generate the plain text emails from the html emails?
It always seemed a bit redundant to maintain both. I imagine they wouldn't look perfect but might be good enough if the primary goal was just to improve email deliverability.
Thanks Ryan!
That's new in OSX Lion.
Okay, figured that out quickly enough. Just used << to append one array to the other.
Here's my newb question. I'd like to search the a related table on multiple attributes, so in the case of comments, search on the content as well as maybe the submitter. However, I'm not sure how to do the mapping to grab two attributes and concatenate them or join them in one array.
Do you have a _message.html.erb partial in your app/views/messages directory?
I ran into the same issue, I resolved it by adding an ignore parameter on the tree method.
I have a Family model (for a product):
In my view partial, I use the following to render a select tag - obviously the id_to_ignore is the family_id of the family I want to exclude in my select tag:
I hope this helps.
Thats a very good way, except when validations fail. Then the id of the created OBJECT gets passed to the view, but when the validation fails, the same OBJECT gets deleted in the ROLLBACK process.
Then when you submit the form again, Rails can´t find the object based of the ID that gets passed on from the view...
Does anyone have a solution to this problem... Maybe some kind of after_validation callback?
The Xcode install comes with gcc which is needed for compilation. You might be able to install gcc separately and get everything working smoothly. gcc isn't listed as a dependency of rvm, but I'm pretty sure it is required to make the rubies.
Great video.
One thing - do you not need to install Xcode first to allow rvm to work?
(Just for context: I'm running SnowLeopard on an older machine. I did have a working installation but naiively thought I could get away with uninstalling Xcode once I'd installed Homebrew)
On Chrome 14.0 and Firefox I am using on Ubuntu, cookies are generated even if I am not checking remember me. I see _auth_session and auth_token in the cookies browser. Both are set to expire when browser is closed. But after I closed the browser and reopened it, I am automatically signed in. Only way to sign out is to click logout.
Does anyone know what could be going on? I am using the original code.
How else would you do it? Hardcoding to .id and a fixed attribute name? record_id is the function name to call to get the id, it could be :id, but also any other function like :permalink for example. attribute needs to be flexible too, otherwise you could use this builder only for one fixed named attribute. Not very practical I guess... ;-)
I'm using the Mail project to send emails:
https://github.com/mikel/mail
Does not seem to work in production like this (I'm precompiling the assets).
Source code isn`t available?
Sweet combination :)
We just went through the painful process of sending fancy html emails on Rails 3.1 a month ago. The CSS in our emails even have media queries so they look right on mobile devices. We used premailer-rails3, but it needed a lot of patching before it worked properly.
Our post about it is here: http://joevandyk.com/post/12980661035/fancy-html-emails-with-rails-3-1
Good episode. Aslo is good to mention the MailView plugin ( https://github.com/37signals/mail_view ) which is really nice way to test without sending the html mails.
I wrote my own gem to do this a few weeks ago, inline_styles_mailer, but it looks like I've got a lot to learn by reading how premailer and roadie work. Thanks Ryan.
I've been working on email marketing for a while now and I have to say that Gmail is the 1st email client that I use to test my emails, but then I have to test in the painful Outlooks... because the majority of clients uses Outlook (Link).
Making emails "work" in Outlook 2007 & 2010 (Windows versions) is painful, because M$ switched the render engine from IE to Word (join your voice at Link) and the Word engine doesn't follow some web standards, so be ready for some headaches.
Important lessons:
* be careful when sending a lot of emails, your email address can get blacklisted very fast
* use several email clients to test your emails
* forget CSS positions
* use a spam tester, to test your email's spam value
* add an unsubscribe link to your email, because it's mandatory (SPAM-CAN laws)
* ...
Some useful resources:
Link
Link
You can skip
require "rubygems"
since Ruby 1.9This is quite interesting. Can you do a similar screencast for handling incoming faxes and then routing them appropriately?
Thanks.
Bharat
Hey Ryan,
First of all nice tutorial. Can you suggest me a way to develop a web based email client that would fetch mail from a domain using pop/imap.
If anybody else have some idea please suggest.
Thanks,
Souvik
+1
I removed the :cli => --drb from the Guard file, as there is the --drb in the .rspec file. It is working now, but growl is not.
Anyone?
Guys, I have everything working fine (spark, guard, rspec, and growl) but when spark runs everything I don't get any spec output through spork?
I just wanted to share a neat way to debug remote JavaScript errors and notify Airbrake that we used in a recent project. Debugging RJS and Airbrake Integration
Hi Ryan,
great episode. I have only one question. How do you stay up to date with the original repository?
Greetings
I really appreciate the thoroughness, like the delegation, the metaprogramming, and including the HABTM example from the other Railscast. Just became a subscriber and this cast was instantly actionable.
great question jDeppen; Ryan, or other commenters come across any solutions for question #2?
@Radha - I use it with RVM in my cap recipe and it works fine. You have to ensure to trust all .rvmrc though via the flag or cron will hang (on the github readme for Whenever).
@Joshua:
Q1 -
namespace :deploy do
desc "write the crontab file"
task :write_crontab, :roles => [:whatever] do
run "cd #{release_path} && sudo whenever --load-file config/anyfile.rb --write-crontab #{application}"
end
end
This should work - each role should have its own whenever file - then use a cap task based on role to deploy each crontab. Credit shared with Gordon Isnor (stackoverflow question #1008530).
Q2 - use this gem - https://github.com/deviantech/capistrano-conditional