Just can't wait for the day when rails3 is released and all gems and plugins are working with rails3.
And of course I'm waiting for the next Railscast ^^
I was waiting for this one to come with the new Rails 3 casts you are pumping out. Arel rocks :)
Thanks Ryan.
Nice introduction.. Thanks for covering the Rails3 changes; it is a lot more enjoyable for me than just reading the blogs. :)
with this new way of doing things, how would you go doing an "or" condition?
In the "Advanced Rails Recipes" book from Mike Clark, recipe 31 illustrates how to prevent train wrecks. According to Clark, train wrecks are long method chains to access attributes. Somehow the new syntax with queries like User.where(:name => "nonsense").order('id').limit(10) looks like a train wreck.
@someone: you can do a "OR query" like this:
cars = Car.where(["color = ? OR color = ?", "black", "red"])
great screencast, thanks Ryan
Wow, Arel certainly cleans things up a lot especially with scopes. Awesome!
@EppO: I believe you can leave out the square brackets:
cars = Car.where("color = ? OR color = ?", "black", "red")
@0x4a6f4672, I think the train wreck analogy mostly applies when you are jumping through many different types of objects and through methods which can return different data. For example:
Article.first.comments.first.user.name
That line is fairly fragile because "first" may return nil. Also if there is a problem it can be more difficult to debug.
These find method calls are very consistent and always return a relation or scope object which behaves the same. I don't see a problem with it.
I'm sold on the new active record queries after watching this screencast. Thanks again for another great, easy-to-digest, screencast.
Great timing with this Railscast!!
2 Q's
1. Would there be an easy way to chain where with OR instead/with AND
2. any ideas why this is happening?
e.g. THIS FAILS
models/post.rb
scope :visible, where("is_public =?", true)
controllers/posts_controller.rb
@posts = Post.where("user_id=?",current_user)
@posts = Post.visible if params[:view_all_posts]
this fails complaining about nil array..
But..THIS WORKS
controllers/posts_controller.rb
@posts = Post.where("user_id=?",current_user)
@posts = Post.where("is_public =?", true) if params[:view_all_posts]
this works...
Ty all,
Thanks Ryan for your great screencast. Looking forward to more Rails 3 screencasts! :)
Have a nice day.
Interesting changes, very clean. I like this a lot more that that bundler business, that's for sure. Unfortunately, even though we're all being encouraged to switch to Rails 3 asap, there are a lot of plugins and gems that are still incompatible. So its going to be a while for me, anyway.
@Greg, no, in the long run it should decrease the number of SQL queries. Since it waits until the last moment before the query happens, there are times the query may not be necessary.
@BrettD, I don't think there is any additional support for OR queries here. You'll still need to use an SQL string in the where clause, but I wouldn't be surprised if a plugin comes out which does add OR capabilities. I have some ideas on how it could be done.
As for your second question, I have no idea why that is failing without seeing the full error message. Feel free to email me: ryan at railscasts dot com.
Hi!
I would love to see your ideas in form of a plugin, ryan. :)
Data Mapper of Merb does provide such a syntax, you can do queries like :age.gt(18) or :name.like("%rails%"). I believe, "or" conditions where possible aswell, but I don't recall the syntax...
iGEL
Thanks for the great screencast Ryan! I'm really looking forward to Rails 3, and the lazy loading features you mentioned should really help performance in database intensive/high-traffic applications. Looks like some REALLY sweet stuff!
I was pretty much unexcited about Rails 3, for the things I've seen so far, but this is really clear and cool!
Consider casting your scraps about controller ?
Ryan, thank you very much for (again) a splendid video.
If you would charge for accessing this site I would gladly pay you.
Thanks!
Ryan,
Thanks for another fantastic episode, keep it up - you're a one man training company !
thanks
Ryan,
Loving the tour of Rails 3 so far. This is amazing content :)
-John
Isn't this exactly like Sequel? Anybody know the of any differences (besides filter => where and those stuff).
Allways like sequel anyways.
More importantly. Is AR now threadsafe (sequal is)
where("hidden != ?", true)
shouldn't that be
where("not hidden") ?
While I see this is different, and possibly better, I am worried about two things.
First, I don't see why this change must occur. It seems that all it is doing is building a SQL query in the background and delaying its execution. Why can't Foo.all delay in exactly the same way, without syntax change?
Second, I used hashes a lot, such as conditions = [ "age < :age", { :age => age }] -- is that syntax actually gone?
I just don't see this as a step forward, but just an incompatible change.
Ryan:
Thanks for yet another wonderful episode!
With respect to your "nifty-generators" gem, will it available in 3.0?
Thanks,
Alex
great job as usual, ryan but please, stop doing casts for rails 3.
- not many use it yet
- it's not stable (things break here and there) and we dont want to waste development time on something that's 3/4 baked.
- please continue to support rails 2.3.5+
thank you, ryan! :)
@James think of it this way; you can spend 10 minutes watching the screencast and have a good idea of what is going on with Rails3, without wasting hours of your time messing with it.
I am still using 2.3.5 too, but I still want to know about 3.0 :)
@James
Rails 3.0 works great as it is right now. Not something you would use in production for sure. But playing with it to learn what's new is great. And Bundler handles dependencies great with Git.
Only downside is the lack of ported plugins. But they are getting there. I'm already using MongoMapper and Formtastic together. Paperclip has a Rails3-branch that was forked too, which works properly with Rails 3.0beta. So it's getting there =)!
@Omar, using "not hidden" will work in SQLite3 but is not database agnostic. I prefer to use SQL queries which can be used in other SQL databases if need be.
@Michael, it appears that the hash syntax you mentioned is still supported.
@Alex, I'm working on upgrading nifty generators to Rails 3, yes.
@James, you're right that Rails 3 is not yet stable and should not be used in production. However I highly recommend everyone give it a try now. Start a small project with Rails 3 or try branching an existing project and upgrading to get an idea of what is involved and report anything that breaks.
Right now a lot of the work needs to be done by the community. One of the biggest roadblocks to upgrading is unsupported plugins. If you want the plugins you use to work with Rails 3 the best thing to do is try it now to see what breaks and report any issues to the developers.
@0x4a6f4672, @Ryan: Ruby 1.9 has introduced slip intermediate operations
into the middle of a call chain, so to prevent the train wrecks you can use tap() method, eg:
Article.first.comments.first.tap {|x| puts x}.user.name
@Ryan, I believe you will find the "not" operator for booleans will work for all databases.
If that was not the case, queries that use "is not null" would never work, surely?
Great screencast! At first glance, I figured the changes were merely for the purposes of being more DRY, but now I see how powerful the benefit of lazy loading can be!
scope :recent, lambda { |*args| {where("created_at > ?",args.first) } }
is this correct?
any ideas as will_paginate and rails3 is breaking
Hi Ryan,
great screencast, as usual!
I have a question: how would I lazy-load #all?
In the controller you did:
@articles = Article.order(...)
What if I wanted to lazy-load all articles? I mean something like:
@articles = Article # would need to implement Enumerable
or some other way to turn Article into an empty Relation.
Technically, I could just create a dummy Relation object as in:
@articles = Article.where('1 = 1')
but that doesn't seem to Railish...
I'm a little late to this party, but a couple of weeks ago I put together a post discussing some interesting things about the kinds of values that are accepted by Relation#where.
In particular, you can feed Arel predicates to #where directly, or for that matter, anything that responds to #to_sql. Kind of neat I think. It's at http://bit.ly/dhSjPJ if you're interested. :)
Another great screencast. How did you "snap" the form information in so quickly? Is there a safari/firefox extension I'm missing?
Money can`t buy Happiness? Whoever said that doesn`t know where to buy.
Buyhermesbirkin offers the high quality Hermes bags and services.
No matter it is the classic Birkin bag, or the Kelly and Lindy bag,
or the latest new designs, you can find them here. Just selecting one,
you will be the next Victoria in the street. – Comes from Shuna Sun
More please, this information helped me consider a few more things, keep up the good work.
Sorry for the huge review, but I'm really loving the articles, and hope this, as well as the excellent reviews some other people have written, will help you decide if it's the right choice for you.
Our discount shop sale many things, such as shoes,cloth, jerseys ect.They will give you an unexpect surprise.Welcime you come to visit them in our discount shop.Our site is http://www.goecshop.com
I was very encouraged to find this site. I wanted to thank you for this special read. I definitely savored every little bit of it and I have you bookmarked to check out new stuff you post.
Sorry for the huge review, but I'm really loving the articles, and hope this, as well as the excellent reviews some other people have written, will help you decide if it's the right choice for you.
Thanks for explanation and for sharing the code. Waiting forward for the next Railscast
Thanks! I had some issues with for performing finds in Active Record. You helped me a lot!
Great stuff from you, man. Ive read your stuff before and youre just too awesome. I love what youve got here, love what youre saying and the way you say it. You make it entertaining and you still manage to keep it smart. I cant wait to read more from you. This is really a great blog
Considerably, this post is really the sweetest on this notable topic. I harmonise with your conclusions and will thirstily look forward to your incoming updates. Saying thanks will not just be sufficient, for the phenomenal clarity in your writing. I will directly grab your rss feed to stay informed of any updates. Admirable work and much success in your business dealings! Please excuse my poor English as it is not my first tongue.
I must admit that this is one great insight. It surely gives a company the opportunity to get in on the ground floor and really take part in creating something special and tailored to their needs.
This is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you (not that I really would want...HaHa). You definitely put a new spin on a subject thats been written about for years. Great stuff, just great!
I was very encouraged to find this site. I wanted to thank you for this special read. I definitely savored every little bit of it and I have you bookmarked to check out new stuff you post.
Couldn?t be written any better. Reading this post reminds me of my old room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thanks for sharing!
This is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you (not that I really would want...HaHa). You definitely put a new spin on a subject thats been written about for years. Great stuff, just great!
I must admit that this is one great insight. It surely gives a company the opportunity to get in on the ground floor and really take part in creating something special and tailored to their needs.
Thank you for another essential article. Where else could anyone get that kind of information in such a complete way of writing? I have a presentation incoming week, and I am on the lookout for such information.
Ryan, thank you very much for (again) a splendid video.
If you would charge for accessing this site I would gladly pay you.
Thanks!
What youre saying is completely true. I know that everybody must say the same thing, but I just think that you put it in a way that everyone can understand. I also love the images you put in here. They fit so well with what youre trying to say. Im sure youll reach so many people with what youve got to say.
Thanks for getting the time to discuss this, I really feel strongly about it and surely reading incredible on this subject. If feasible, as you obtain expertise, would you mind updating your weblog with really good information and facts? It truly is basically valuable for me.
This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses.
This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.
Considerably, this post is really the sweetest on this notable topic. I harmonise with your conclusions and will thirstily look forward to your incoming updates. Saying thanks will not just be sufficient, for the phenomenal clarity in your writing. I will directly grab your rss feed to stay informed of any updates. Admirable work and much success in your business dealings! Please excuse my poor English as it is not my first tongue.
This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion.
That fantabulous post this has been. Within no way seen this kind associated with useful post. I’m grateful to you and anticipate much more associated with posts such as. Thank you very much.
Aw, this was a really great post. In theory I'd like to write like this also - taking time and real effort to make a good article... but what can I say... I procrastinate alot and never seem to get something done.
The beauty of these blogging engines and CMS platforms is the lack of limitations and ease of manipulation that allows developers to implement rich content and 'skin' the site in such a way that with very little effort one would never notice what it is making the site tick all without limiting content and effectiveness.
Thank you, all of information from this site very useful.
I also has a good website about Most Intelligent Animal
in "http://www.worldinterestingfacts.com/animal/top-10-most-intelligent-animals-in-the-world.html".
Maybe You can take a look at my website as well.
Thanks
Great Article, Thanks.
I also has a good website about Most Intelligent Dog
in "http://www.worldinterestingfacts.com/animal/top-10-most-intelligent-dog-breeds-in-the-world.html".
Maybe You can take a look at my website as well.
Thanks
This article is very interesting.
I also has a good website about Most Expensive Laptop
in "http://www.worldinterestingfacts.com/lifestyle/top-10-most-expensive-laptop-computers-in-the-world-that-you-may-want-to-put-beside-your-business-folders.html".
Maybe You can take a look at my website as well.
Thanks
Ruby on Rails is separated into various packages, namely ActiveRecord , ActiveResource, ActionPack, ActiveSupport and ActionMailer. Prior to version 2.0, Rails also included the Action Web Service package that is now replaced by Active Resource. Apart from standard packages, developers can make plugins to extend existing packages.
Hrmm that was weird, my comment got eaten. Anyway I wanted to say that it's nice to know that someone else also mentioned this as I had trouble finding the same info elsewhere. This was the first place that told me the answer. Thanks.
This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.
Finally, an issue that I am passionate about. I have looked for information of this caliber for the last several hours.
Couldn?t be written any better. Reading this post reminds me of my old room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thanks for sharing!
Great stuff from you, man. Ive read your stuff before and youre just too awesome. I love what youve got here, love what youre saying and the way you say it. You make it entertaining and you still manage to keep it smart. I cant wait to read more from you. This is really a great blog.
This is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you (not that I really would want...HaHa). You definitely put a new spin on a subject thats been written about for years. Great stuff, just great!
Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.
Thank you for another essential article. Where else could anyone get that kind of information in such a complete way of writing? I have a presentation incoming week, and I am on the lookout for such information.
I was very encouraged to find this site. I wanted to thank you for this special read. I definitely savored every little bit of it and I have you bookmarked to check out new stuff you post.
I admire the valuable information you offer in your articles. I will bookmark your blog and have my children check up here often. I am quite sure they will learn lots of new stuff here than anybody else!
I recently came across your blog and have been reading along.
I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading.Nice blog,I will keep visiting this blog very often.
love converse all star,love yourself.High quality low price.It's fit for you.
Nice information, Thanks. I think you have simple and unique blog
This is my first time I visit here. I think, this is perfect blog. Thank you very much
Thank you for this post. I am new to your blog and get really very nice. I will keep visiting your blog.
Hey very nice blog!!Beautiful .. Amazing .. I will bookmark your blog and take the feeds also
Pretty good post.I found your website perfect for my needs. thanks for sharing the great ideas.
That line is fairly fragile because "first" may return nil. Also if there is a problem it can be more difficult to debug.
Hey, just looking around some blogs, seems a pretty nice platform you are using. I'm currently using Wordpress for a few of my sites but looking to change one of them over to a platform similar to yours as a trial run. Anything in particular you would recommend about it? .I must admit that this is one great insight. It surely gives a company the opportunity to get in on the ground floor and really take part in creating something special and tailored
I have always liked Outdoor movies, a child standing at the window, looked out from home to
the following. Will be able to see the staff busy figure, a huge white cloth has a child
hang up and soon will be able to see the movie.
The beauty of these blogging engines and CMS platforms is the lack of limitations and ease of manipulation that allows developers to implement rich content and 'skin' the site in such a way that with very little effort one would never notice what it is making the site tick all without limiting content and effectiveness.
Thank you for another essential article. Where else could anyone get that kind of information in such a complete way of writing? I have a presentation incoming week, and I am on the lookout for such information.
I was very encouraged to find this site. I wanted to thank you for this special read. I definitely savored every little bit of it and I have you bookmarked to check out new stuff you post.
This is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you (not that I really would want...HaHa). You definitely put a new spin on a subject thats been written about for years. Great stuff, just great!
Simply, admirable what you have done here. It is pleasing to look you express from the heart and your clarity on this significant content can be easily looked. Remarkable post and will look forward to your future update.
Let me start by saying nice post. Im not sure if it has been talked about, but when using Chrome I can never get the entire site to load without refreshing many times. Could just be my computer. Thanks.
I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will find that very useful
Fantastic screencast! Helped me refactor some similar stuff I had been doing with Rails and jQuery. i love your articles youre always giving me great ideas on how to progress with my blog. thanks a lot for keeping us informed.
Great post this will enhance the reader, very informative articles.
thanks for sharing.
Interesting post.thanks for posting. I’ll likely be coming back to your blog. Keep up great writing.
Your post is really amazing as it provide visitors with great knowledge.
Wonderful article, thanks! This is obviously one great post. Thanks for the valuable information and insights you have so provided here
This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.
I very much enjoyed your website. Excellent content
I just want to say that you're a great blogger.
Thanks for a good share
Pretty good post.I found your website perfect for my needs. thanks for sharing the great ideas.
Very nice and helpful information has been given in this topic. Keep working. Thanks. . .
Thanks, all information from this site very useful.
What youre saying is completely true. I know that everybody must say the same thing, but I just think that you put it in a way that everyone can understand. I also love the images you put in here. They fit so well with what youre trying to say. Im sure youll reach so many people with what youve got to say.I was very encouraged to find this site. I wanted to thank you for this special read. I definitely savored every little bit of it and I have you bookmarked to check out new stuff you post.
I was very encouraged to find this site. I wanted to thank you for this special read. I definitely savored every little bit of it and I have you bookmarked to check out new stuff you post. this post is really the sweetest on this notable topic. I harmonise with your conclusions and will thirstily look forward to your incoming updates. Saying thanks will not just be sufficient, for the phenomenal clarity in your writing. I will directly grab your rss feed to stay informed of any updates. Admirable work and much success in your business dealings! Please excuse my poor English as it is not my first tongue.
Thanks for sharing your article. I really enjoyed it. I put a link to my site to here so other people can read it. My readers have about the same interets
Hi,How to fit the large string into single textbox without breaking the word in active reports.
I like your taste, the actual fact that your site is a tad bit different makes it so helpful, I get completely fed up of discovering the same stuff almost all of the time. I have I just stumbled on this page by you Appreciate it.
Hi Ryan,
I hope this comment does not get lost in all the spam that has filled your page :(
I am using pg adapter(postgres) instead of sqlite3.
While playing with the console I found that when i do Article.order("name") i do not get a list ActiveRecord::Relation objects(as shown in the screencast). You spoke about lazy-loading.. this however does not seem to work with the setup that i have. I instead get the entire list of articles (as you would if you did Article.order("name").all).
Has it got anything to do with the postgres adapter?
Is this a bug that needs to be reported?
Thanks,
Shripad
Great post! Im just starting out in community management/marketing media and trying to learn how to do it well - resources like this article are incredibly helpful.I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will find that very useful As our company is based in the US, it?s all a bit new to us.
I admire the valuable information you offer in your articles. I will bookmark your blog and have my children check up here often. I am quite sure they will learn lots of new stuff here than anybody else!
I was very encouraged to find this site. I wanted to thank you for this special read. I definitely savored every little bit of it and I have you bookmarked to check out new stuff you post.
Thanks for covering the Rails3 changes; it is a lot more enjoyable for me than just reading the blogs. :)
Let me start by saying nice post. Im not sure if it has been talked about, but when using Chrome I can never get the entire site to load without refreshing many times. Could just be my computer. Thanks.
Simply, admirable what you have done here. It is pleasing to look you express from the heart and your clarity on this significant content can be easily looked. Remarkable post and will look forward to your future update.
This is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you (not that I really would want. You definitely put a new spin on a subject thats been written about for years. Great stuff, just great!
Finally, an issue that I am passionate about. I have looked for information of this caliber for the last several hours. Your site is greatly appreciated.I will bookmark your blog and have my children check up here often. I am quite sure they will learn lots of new stuff here than anybody else!
Excellent information. I found your website perfect for my needs
this site very useful. I think you have unique and simple blog
This is really a nice guide for Newbies like me. Thank you.
admirable what you have done here. It is pleasing to look you express from the heart and your clarity on this significant content can be easily looked. Remarkable post and will look forward to your future update.You make it entertaining and you still manage to keep it smart. I cant wait to read more from you. This is really a great blog.






