RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Oh. I found it. You answered it already to one.
tail -f log/development.log
was it.

Avatar

Hey.

I really like your railscasts. I haven't miss any :).

I have one question:
You look your log messages from live console. Is there some program or smth?

Avatar

A "gotcha" of this method of HABTM check box handling is that you lose some UI functionality. Because each of your check boxes will have NAME and VALUE like "model[habtm_relationship_ids][]", you can't pair them with a label in a manner that clicking on said label selects the checkbox.

Avatar

Thanks for the answers. KeyCastr is a very good idea for screencasts.

I’ve been using Locomotive on Mac OS X for my Rails development, so I hadn’t been calling script/server directly. I had also just been opening my logs in Textmate or TextWrangler, so hadn’t realized there was pretty-printing that would pick up in tail.

Thanks again!

Avatar

@Yoann,

I just hit "OK" and then restarted my development server and the plugin worked. What error message are you getting and what version of Rails do you have?

Avatar

I really enjoy your screencasts.

Could you describe how you installed the textmate plugin in this episode ? I got an error while trying to do the same.

Avatar

@ben: Definitely. You're probably manipulating a page that _only_ has check boxes. Since a form of only check boxes (with none selected) won't submit anything for that param you have to handle the 'nil' exception.

It should also be noted that has_many relationships _do_ have a #relationship_ids= method, but has_many :through relationships don't.

Avatar

I wished I'd seen this before I installed acts_as_authenticated! I'll certainly use this for my next simple app!

Avatar

This is just what I was looking for in a simple admin system. I'd already installed the RESTful Authentication plugin, but I'll probably pull it out and replace it with your simple system as shown in RailsCast #21 (http://railscasts.com/episodes/21). I only need to Admin it, not have personalized users. I saw hints of this in the PeepCode on Caching (http://www.peepcode.com/products/page-action-and-fragment-caching)

Avatar

Great stuff -- I had no idea you could do that, and I learned some things about migrations too.

Thank you!

Avatar

This is interesting. I probably never would have done this think it was redundant data. Thanks once again.

Avatar

This approach is pretty useful, but won't it complicate caching down the line?

Avatar

@Jack, maybe someday I'll get more contributors to Railscasts, but at the moment I like to keep things simple and controllable.

@Ryan, an episode on modules and mixins is a great idea. I'll add it to my list. :)

@Grant, the live display of the development.log file is just coming from when I run "script/server", I guess mongrel is automatically set up to display this. If it's not displaying it for you, you can run this command (probably won't work on Windows)

tail -f log/development.log

The keystrokes are being displayed using KeyCastr.

http://stephendeken.net/software/keycastr/

Thanks for the encouraging comments folks!

Avatar

Nice job. I really liked the migration part.

Avatar

Clear, concise, and very useful. Thanks for your excellent Railscasts.

What are you using to get the pretty-printed live display of your development.log in the Terminal?

What are you using to get command-key strokes displayed in that little popup near the top right?

Thanks!

Avatar

I used this screencast to create a checkbox list for a posts/categories relationship and found that in post/update where you have "params[:post][:category_ids] ||= []" that I had to add a "rescue nil" at the end up that line to make tests happy. Think I did the right thing?

Avatar

I enjoy the screencasts. Some of them I find to be a little too basic, but I often get something worthwhile out of them. I do, however, like the path you're taking--it seems like the topics are getting more and more in-depth.

As a future request, I would love to see a screencast or two on modules and mixins. I'm starting to get into meta-programming, but I find it really, really confusing in the beginning.

Keep up the good work!

Avatar

Have you ever considered getting more coders on board to contribute railcasts? I ask purely out of greed, I just can't get enough or RoR screencasts :)

Avatar

@Pepe, the "_path" method is called a named route. This is generated automatically when you are doing a RESTful design. I'll try to cover it in a future episode.

Great idea, thanks.

Avatar

Congratulations ;)
Ryan can you explain the link_to xxx, xxx_path(xxx)? I tried it and it didn't work.

Avatar

@Rebort,

Great ideas, thanks. I'm trying not to add to the amount of work for each episode, but I'll give it some serious consideration.

The ||= operator is described in the very first episode on caching with instance variables.

Avatar

Love the screencasts and the recent additions of the site.

Have you thought about doing screenshots or having sample code up next to each video?

The reason I ask -- I'm trying to remember something you did with a User model and the =|| operator, but I can't remember which video it was in!

Anyway -- thanks for sharing the knowledge and putting out a great site!

Avatar

Railscasts are coming soon to an AppleTV or iPod near you.

Avatar

I should have made this more clear in the episode:

An instance variable only sticks around for a single request, so using the technique described will only benefit you if you need to call a method multiple times per request.

If you need to store a model or other data between requests, look into memcached.

Avatar

I love Railscasts, it's a simple no fuzz approach to learning rails. I do wish I could watch the podcast on my Apple TV however. Just a thought. Keep up the good work!!!

Avatar

@Jon,

Good question, I should have mentioned this in the screencast. You need to check if the user is logged in first:

def admin?
  logged_in? && current_user.admin?
end

Untested.

Avatar

@Hugh,

Good point, I should have mentioned this in the screencast. You can avoid name clashes by specifying the table name in front of any mentioned column name. For example:

Topic.find(:all, :include => :project, :order => 'topics.name')

You can do the same in the conditions parameter and anywhere else.

Note to self: add some code formatting in comments.

Avatar

Hey, super cool casts you make ;)
Can you make a screencast about using and integrating acts_as_auth or restfulauth ?

Avatar

Hey, man. Great work! Really helped me get going.

Is this the place to ask questions? I'm trying out acts_as_authenticated, and have hit one snag based on the helper method you wrote in the screencast. From what I can tell, current_user.name throws an error if the public tries to access the page without being logged in. I'm sure it's a simple fix, but I thought I'd point that out. And see if you had a quick solution.

!Jon

Avatar

Hey Ryan,

  Thank you for putting out great screencasts. Great work. Great quality. Awesome contribution to the community.

Avatar

Nice screencast.

Do you ever get name clashes with eager loading? IE, since a project and a task both have the column 'name', when using eager loading you might get a Invalid SQL exception.

Avatar

Thanks everyone for the encouraging comments.

@Ted: I think you'll only see a boost in performance if you're displaying the comment and user name for each task in the list. Each task will need an additional query to fetch the comments, and each comment would need another query to fetch the user name. If you're displaying a significant number of tasks with comments then this can get out of control. Eager loading will reduce this all to one big query with lots of joins.

That said, if you're just displaying the number of comments and not the entire comment content, you won't see much of a boost in performance with eager loading because it will be fetching more information from the database (the content of the comment) and not just the number of comments. I cover this problem in the next episode.

Avatar

Just to echo the praise above, thank you! I too look forward to seeing an update in my RSS reader; keep up the great work.

Avatar

Great stuff as usual.

I'd like to have seen the before and after results of including comment and user counts on the task list and how the database queries were affected when you added them to the find include.

Avatar

Thanks, I put it on the Rails Security Project: http://www.rorsecurity.info/