I've got a field thats validated as validates_length_of :badge_id, :is => 12, :message => "ID must be 12 digits", :unless => Proc.new{|r| r.badge_id == '0'} which is causing the following error - this only goes away if I remove the :message => "..." from the above validation:
I18n::InvalidPluralizationData in Registrants#new
translation data {:record_invalid=>"Validation failed: %{errors}", :taken=>"has already been taken"} can not be used with :count => ID must be 12 digits
This column is a string and is also validated as validates_numericality_of :badge_id, :only_integer => true
I get the following error after I've set up the rails pre RVM, installed rails --pre and then try to run rails / rails -v:
ruby
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:925:in`report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:243:in `activate_dep'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:235:in `activate'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:1306:in`gem'
from /usr/local/bin/rails:18:in `<main>'
If I do ruby -v it outputs ruby 1.9.2p180, but there looks like there is a linking error or something, any ideas?
I love the way livereload only reloads the stylesheet, not the entire page - great for AJAX preview. I was having temperamental results when trying to get guard-livereload and guard-sass to work together... I could reload the entire page after a sass file is changed, but not the stylesheet alone. If anyone has a solution, please share.
@Ken Hart: I guess it depends on your page structure. If your page rely on lots of heavy JS and CSS and this big background is simply for extra eye candy, I believe loading it after all the rest to be a better choice. However if your page have only this big image as heavy thing, yes, streaming will be great as starting it's download as soon as possible, ending up with a faster page load.
Hey Ryan, would a good use-case for streaming be for a landing page like Groupon, where the background image is very large and could take some time to load? Or is it more for javascript intensive pages?
Just a note... if you use this in combination with RailsCasts #154 to give ancestry to comments, make sure you ignore parent_id in the method find_commentable or you'll encounter the error 'uninitialized constant Parent'. Oops!
At first I thought this would be a way to display updates to an area of the screen when you fire off a long running task on the server from a specific web page and update the user about the progress. Say you wanted to keep the user informed about a process that reaches out to 4 or 5 other sources to assemble information, and you have a div where you want to report the status of each different source as it comes in. It doesn't sound like you'd use HTTP streaming for this though, right? Better to just use a combination of AJAX and JS here.
As for streaming it self i think that it's a great feature if you use it properly. Personally i would jump into it with my eyes covered ;)
@Markus: what kind of problems are you writing about?
@Ryan: i really appreciate the new look - it's amazing. Unfortunately I have to agree with Javi about the music :( Please, let it be more soothing :) (i'm sorry for pointing this out)
If your app was to take 20-30 seconds to load the view the browser would hang and show no signs of a response until finished. With this it would load the title etc... and give the end user some sign that its working.
Although I would rather have it load a page saying "loading..." and fire of a ajax request for the data so the user has a complete page and then the data can take as long as it wants.
We have a CSV download that we generate while streaming it to the client. We can generate it at about 1megabyte/second so it makes sense to start sending it to the client as soon as possible. We are using a custom library to enable this today but I'm happy to see it available in Rails 3.1.
Does anyone know if it's possible to programmatically call the streaming yield?
Doesn't streaming allow concurrent browser loading and caching? So for example, you can set it so your browser pulls in more HTTP requests at the same time or would this not apply to that?
@Markus
Plus caching of the files are beneficial. The version numbers at the end of the file that change when the file is changed would make it so the file is grabbed again when the user hits it. Otherwise it will remain cached and provide a faster experience.
You gain much speed for the first visit by a user and also the grouping of all js files and all CSS files into one compressed files reduces the number of requests by quite a bit.
A Rails 3 and before app would be quite slow from the viewpoint of the front end user experience and streaming should help a lot.
I don't think I'll be using HTTP Streaming much but its nice to have the option. What I'm really looking forward to are the upcoming screencasts on SASS and CoffeeScript!
Hi Markus,
I agree with you in case of rendering page layout. But imagine situation when you have to load huge amount of json data like rendering huge dynamic charts, maps, etc. In that case you are able to serve these data much quicker to users.
It should be mentioned that for the custom validation to work, the lib directory must be loaded with config.autoload_paths += %W[#{config.root}/lib/] in application.rb.
Thanks Ryan! Great cast. But exists a version for rails 2.x? I have an Rails 2.x app, I cannot upgrade to 3 because of some main plugins still not available for rails 3.
A couple of tweaks to the show notes. Lemme preface this with I'm on rvm 1.6.9 and ruby 1.9.2-p180.
The first show note command makes use of an "undocumented feature" of rvm by switching to the gemset after it gets created. It might be better to get into the habit of using the documented way, with the "use" command:
rvm use 1.9.2@railspre --create
Next, I was getting rails-3.0.7.rc2 instead of rails-3.1.0.beta1 (can anyone explain why?). I tried explicitly asking for the 3.1.0.beta1 version with the -v option but that got me 3.0.0.beta2. However, I fixed that by updating the gems with the --pre option:
gem update --pre
Of course, this is overkill. Not sure why that worked but the gem install rails --pre didn't.
Interestingly,
:unless => ...
overrides theis:
validation. I'm forced to go withvalidates_length_of :badge_id, :is => 12
The issue is it defaults to displaying
instead of
digits
. Hmm!Hello Ryan, really cool cast as always :)
I've got a field thats validated as
validates_length_of :badge_id, :is => 12, :message => "ID must be 12 digits", :unless => Proc.new{|r| r.badge_id == '0'}
which is causing the following error - this only goes away if I remove the:message => "..."
from the above validation:This column is a string and is also validated as
validates_numericality_of :badge_id, :only_integer => true
Thanks!,
Mike
Hey! For those who have undefined method `klass' for nil:NilClass error see the following stackoverflow thread http://stackoverflow.com/questions/5746006/has-many-through-nested-form-that-can-build-multiply-insctance
What is the CSS code used for the announcement div?
Good idea. I'm going to do that in my app that uses this.
Completely agree with this, I hope there is a supported way to not have to load a single large file.
Are these new roles going to phase out CanCan?
Thanks Dan.
I get the following error after I've set up the rails pre RVM, installed rails --pre and then try to run rails / rails -v:
If I do ruby -v it outputs ruby 1.9.2p180, but there looks like there is a linking error or something, any ideas?
I love the way livereload only reloads the stylesheet, not the entire page - great for AJAX preview. I was having temperamental results when trying to get guard-livereload and guard-sass to work together... I could reload the entire page after a sass file is changed, but not the stylesheet alone. If anyone has a solution, please share.
Yes, Passenger supports Streaming both on Apache and Nginx
Yes, Passenger supports Streaming both on Apache and Nginx.
Great screencast and nice addition.
@Ken Hart: I guess it depends on your page structure. If your page rely on lots of heavy JS and CSS and this big background is simply for extra eye candy, I believe loading it after all the rest to be a better choice. However if your page have only this big image as heavy thing, yes, streaming will be great as starting it's download as soon as possible, ending up with a faster page load.
does 3.1 now give you error pages in development mode?
Hey Ryan, would a good use-case for streaming be for a landing page like Groupon, where the background image is very large and could take some time to load? Or is it more for javascript intensive pages?
Same question. Does the combo Apache/Passenger support treaming?
Just a note... if you use this in combination with RailsCasts #154 to give ancestry to comments, make sure you ignore parent_id in the method find_commentable or you'll encounter the error 'uninitialized constant Parent'. Oops!
The link to Advanced Rails Recipes is broken.
+1000 for SASS with Coffee ;)
At first I thought this would be a way to display updates to an area of the screen when you fire off a long running task on the server from a specific web page and update the user about the progress. Say you wanted to keep the user informed about a process that reaches out to 4 or 5 other sources to assemble information, and you have a div where you want to report the status of each different source as it comes in. It doesn't sound like you'd use HTTP streaming for this though, right? Better to just use a combination of AJAX and JS here.
Hey Ryan! Another great episode :)
As for streaming it self i think that it's a great feature if you use it properly. Personally i would jump into it with my eyes covered ;)
@Markus: what kind of problems are you writing about?
@Ryan: i really appreciate the new look - it's amazing. Unfortunately I have to agree with Javi about the music :( Please, let it be more soothing :) (i'm sorry for pointing this out)
Ryan - first 2 layouts don't work at all of for me. divs are layered on top of each other, and it's impossible to use.
Also everything is aligned to the left ( but according to your video it should be centered). Doesn't matter how I resize my browser.
Here are screenshots of how it looks on my screen:
Skewed Layout 1
Skewed Layout 2
Skewed Layout 3
I'm using FireFox 4 on Windows XP sp3, on a 23 in monitor using 1980 x 1080 resolution.
Other than that I like new design - it's even more convenient than before.
EDIT:
Everything looks fine in latest Chrome & Safari. IE 8 seems to be ok too.
Ryan doesn't do the ASCIIcasts, that's handled by a fine fellow named Eifion Bedford. Check out his about page.
If your app was to take 20-30 seconds to load the view the browser would hang and show no signs of a response until finished. With this it would load the title etc... and give the end user some sign that its working.
Although I would rather have it load a page saying "loading..." and fire of a ajax request for the data so the user has a complete page and then the data can take as long as it wants.
Hi Ryan.
No more ASCIICasts? I guess, I was the only fan of them.
Very nice redesign btw.
We have a CSV download that we generate while streaming it to the client. We can generate it at about 1megabyte/second so it makes sense to start sending it to the client as soon as possible. We are using a custom library to enable this today but I'm happy to see it available in Rails 3.1.
Does anyone know if it's possible to programmatically call the streaming yield?
Doesn't streaming allow concurrent browser loading and caching? So for example, you can set it so your browser pulls in more HTTP requests at the same time or would this not apply to that?
@Markus
Plus caching of the files are beneficial. The version numbers at the end of the file that change when the file is changed would make it so the file is grabbed again when the user hits it. Otherwise it will remain cached and provide a faster experience.
Is streaming supported by Passenger?
You gain much speed for the first visit by a user and also the grouping of all js files and all CSS files into one compressed files reduces the number of requests by quite a bit.
A Rails 3 and before app would be quite slow from the viewpoint of the front end user experience and streaming should help a lot.
I don't think I'll be using HTTP Streaming much but its nice to have the option. What I'm really looking forward to are the upcoming screencasts on SASS and CoffeeScript!
Hi Markus,
I agree with you in case of rendering page layout. But imagine situation when you have to load huge amount of json data like rendering huge dynamic charts, maps, etc. In that case you are able to serve these data much quicker to users.
Yay! They finally ported all the problems PHP has to rails!
I see no advantage when your JS and CSS assets are properly cached by the browser, but a lot of problems.
Is it possible to use it with nginx or apache?
You can do this:
@search = Product.search(params[:search])
@search.meta_sort ||= 'name.asc'
(Source: http://craiccomputing.blogspot.com/2010/10/searchlogic-versus-metasearch-and.html )
hi ryan if you click the rely link twice the form shows up twice. could this be fixed
It should be mentioned that for the custom validation to work, the lib directory must be loaded with
config.autoload_paths += %W[#{config.root}/lib/]
in application.rb.Please ignore the above! I had some file corruption causing this
These 2 links might assist :
https://github.com/johnzan/railscasts-episodes-episode-197
http://thoughtsincomputation.com/posts/dynamic-nested-forms-in-rails-3
Regards! akza
http://www.bleet.co.za
For anyone reading this thread controller inheritance in Rails 3.0.3 has totally stuffed OO development principles for controllers.
I've raised a ticket here https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6783-rails-303-controller-inheritance-is-broken.
I'm checking out 3.1 to see if this is still an issue and I'll post back here if it is.
Thanks Ryan! Great cast. But exists a version for rails 2.x? I have an Rails 2.x app, I cannot upgrade to 3 because of some main plugins still not available for rails 3.
I found this: https://github.com/dnclabs/client_side_validations But it seems outdated. Does anyone can help?
Thanks!
Martin
Nice update, although to save you bandwidth and client load time, the AJAX loading could be cached upon first load.
Example: If you click the 'Comments' tab, then 'Similar Videos', then back to 'Comments', it sends a second AJAX call for the comments view.
Also, the Profile pages have bugged headings.
https://github.com/guard/guard-ego :)
What didn't work for you? Please open an issue on github with more info. I'll be happy to help you.
Nice job with the new design!
Not to sound picky but, any plans to have mkv format as well?
I figured it out. Using Ubuntu 11.04, do the following:
Install scons:
sudo apt-get install scons
Add mustang to your Gemfile:
gem 'mustang'
Run bundle.
Excellent work on your new site's look and feel, Ryan.
A couple of tweaks to the show notes. Lemme preface this with I'm on rvm 1.6.9 and ruby 1.9.2-p180.
The first show note command makes use of an "undocumented feature" of rvm by switching to the gemset after it gets created. It might be better to get into the habit of using the documented way, with the "use" command:
Next, I was getting rails-3.0.7.rc2 instead of rails-3.1.0.beta1 (can anyone explain why?). I tried explicitly asking for the 3.1.0.beta1 version with the -v option but that got me 3.0.0.beta2. However, I fixed that by updating the gems with the --pre option:
Of course, this is overkill. Not sure why that worked but the
gem install rails --pre
didn't.Its worth mentioning that you need to remove 'config/initializers/new_rails_defaults.rb' If you have one (as mentioned in the file's comments).
Otherwise you get an error like
undefined method 'generate_best_match=' for ActionDispatch::Routing:Module (NoMethodError)
Great Post!
The
@template
instance variable is no longer available in Rails 3.Instead you can use this:
Hope this helps :)
Love the new design!