RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Well done Ryan, fantastic job on your 100th Screen cast.

Here is my first tip :)

http://lindsaar.net/ruby-on-rails-tips/

Regards

Mikel

Avatar

Greetings and congrats from Portland!

I've been an employed rails developer for 6 months now and railscasts have been the most helpful and reliable resource I've come across.

Thanks Ryan!

Avatar

Thanks for all the great episodes.

Avatar

re: Optional Locals

I prefer to handle optional locals in the partial itself. I like how it keeps the relevant pieces together in one file.

Add code like this to the top of your partial:
<% if local_assigns[:local_value_name].nil? then local_value_name=default_value end %>

Avatar

Thank you.
Keep on going!!
Greetings from Austria

Avatar

Congratulations!!!
Great work!!!
Thank you from Brazil

Avatar

My 2 cents. I've modified it to work with Rails 2.0 CSRF and the UJS plugin.

template:
<%= link_to_destroy 'Remove', user_path(user), delete_user_path(user) %>

helper:
def link_to_destroy(name, url, fallback_url)
    options = "action: '#{url}'"
    if protect_against_forgery?
      options << ", token_name:'#{request_forgery_protection_token}'"
      options << ", token_value:'#{escape_javascript form_authenticity_token}'"
    end
    link_to name, fallback_url, :onclick => "confirm_destroy(event, this, {#{options}})"
  end

javascript:
var confirm_destroy = function(event, element, options) {
if (confirm("Are you sure?")) {
var f = document.createElement('form');
f.style.display = 'none';
element.parentNode.appendChild(f);
f.method = 'POST';
f.action = options.action;
var m = document.createElement('input');
m.setAttribute('type', 'hidden');
m.setAttribute('name', '_method');
m.setAttribute('value', 'delete');
f.appendChild(m);
if(options.token_name && options.token_value){
var s = document.createElement('input');
s.setAttribute('type', 'hidden');
s.setAttribute('name', options.token_name);
s.setAttribute('value', options.token_value);
f.appendChild(s);
}
f.submit();
}
Event.stop(event);
return false;
};

Avatar

Thank you Ryan for your screencasts - I look forward to them each week. I have certainly learnt a lot from your tutorials.

I there any reason I can't get them onto my iPhone? I subscribed using iTunes, but I still can't get them onto the iPhone.

Avatar

Awesome work, Ryan! I'll be here waiting for every one of the next 100!!

Avatar

Uhm, now not encoded:

<%- 3.times do -%>
<p>test</p>
<%- end -%>

results in:

<p>test</p>

<p>test</p>

<p>test</p>

Avatar

@Carl, sure:

&lt;%- 3.times do -%&gt;
&lt;p&gt;test&lt;/p&gt;
&lt;%- end -%&gt;

results in:

&lt;p&gt;test&lt;/p&gt;

&lt;p&gt;test&lt;/p&gt;

&lt;p&gt;test&lt;/p&gt;

I have no idea why...

Avatar

@Jeff, thanks for posting this! I included the link in the show notes.

@Chris, good eye. I modified the code slightly from the Advanced Rails Recipes book by moving some into the "fields_for_task" helper method. For simplicity, the recipe in the book does this inline in the view using a local variable, but recommends moving it into a helper method. Since that note wasn't included here I wanted to encourage the best practice of not setting variables in the view. The code itself still does the same thing, it's just moved around a bit.

Avatar

@Paul, did you add the minus sign on both tags? <%- ... -%> for example?

Avatar

I cannot get tip #1 to work. I still have those pesky newline characters. Is it available in Rails edge only?

Avatar

Didn't watch the screencast, only checked out the text examples, so you might have covered this:

Another way to deal with optional locals is to use <code>local_assigns[:the_local]</code> in the partial. Will be <code>nil</code> if not assigned.

Avatar

Ryan,

 First, please delete the previous comment -- not sure what happened!

 Second, I've been enjoying Railscasts for a while. It's a great service you do here, and the site was instrumental in picking up the basics of Rails.

 You might be interested in a post I did that does a slightly more complex version of a model search, which I still call "simple model search." It's not as simple as the one you provided here, but it does actually let you largely duplicate your data entry forms, access a "Search" model instead of the normal model you'd call with form_for.

Anyway, it's at http://thebalance.metautonomo.us/2008/02/07/simple-model-search-with-rails/ if you're interested.

Avatar

Ryan, This really is a great achievment and an amazing contribution from you to this fantastic community, Thanks and Well Done!

Avatar

Ryan, seriously, you rock!
Concratulations for hitting the 100.
Keep on the good work, you helped me and others way more than any other rails resource (except the api of course ;) )
Greetings from Germany,

Pascal

Avatar

Thanks and CONGRATULATIONS for your's 100 episodes. Keep the great work. You're really good on it and very easy to understand.

Avatar

Congrats!

You make me a better programmer, and you definitely make the monday morning a great morning.

Up to the next 100!

Avatar

The 100 most useful rails screencasts. Thank you!

Greetings from Spain.

Avatar

Congratulations!!

You are a good presenter and an excellent teacher. I watched each of the episodes from day one and learnt a lot. Keep up the good work.

Thank you very much.

Avatar

Internet Explorer needs var added to new variables to avoid the 'Object or method not found'

// javascripts/dynamic_states.js.erb
var states = new Array();
<% for state in @states -%>
  states.push(new Array(<%= state.country_id %>, '<%=h state.name %>', <%= state.id %>));
<% end -%>

function countrySelected() {
  var country_id = $('person_country_id').getValue();
  var options = $('person_state_id').options;
  options.length = 1;
  states.each(function(state) {
    if (state[0] == country_id) {
      options[options.length] = new Option(state[1], state[2]);
    }
  });
  if (options.length == 1) {
    $('state_field').hide();
  } else {
    $('state_field').show();
  }
}

document.observe('dom:loaded', function() {
  countrySelected();
  $('person_country_id').observe('change', countrySelected);
});

Avatar

Congratulation!
Thanks again!

Avatar

Congratulation for your 100th screencast :)

Avatar

Thanks for 100 great screencasts, Ryan!

Here's to another hundred! :)

Avatar

"Congratulations! " * 100
"Thank You! " * 1.0e6

Avatar

You are one of those guys who makes the whole open source-ness of Ruby/Rails so successful as a community. Big thanks and keep it up!

Avatar

Congratulations man, great work.

Avatar

Congrats on your 100th episode. I've watched them since day one and learned a lot of stuff from it. These screencasts are definitely one of the best sources for any rails programmer.

Btw, ROFL about the intro sound. Will you keep it in future episodes? :-D

Avatar

I have to second nicolash's comment. And here I was thinking you forgot our request. I just about burst out laughing when I heard the sound! Great contest BTW, I will have to see what I can come up with for an entry.

Avatar

Hello, there Ryan!

I've been doing a GREAT work, and I'm pretty sure that almost every Rails developer out there has learned something from at least one of your videos.

They make big difference when facing common problems we all have during work, and releasing the 100th just proves that people like your tips and that they are important to many.

Keep up the good job, and most importantly THANK YOU!

Avatar

Thank you for all the great tutorials. This is a fantastic site!

Avatar

Congrats...
and i like the new sound at the end of your intro... hope you didn't kill a mouse for this? ;-)

Avatar

Great job bro and congratulations on your 100 episodes! I know you've worked really hard at it and it shows.

Your Proud Sister,
Sarah

Avatar

Great stuff Ryan. Congrats on the 100 episodes. Thanks again!

Avatar

Thanks a ton for all of your help and hard work in contributing to the Ruby and Rails communities. These screencasts are truly a blessing!

Avatar

You have a very nice collection of screencasts now, Ryan. I recommend them often, and I really like the short focused format.
Congratulations on episode 100!

Avatar

I have been a fan of your screencasts for almost a year now ... congratulations on the 100th episode

Regards
Prateek Dayal

Avatar

100 episodes, time to break out the champagne! Congrats Ryan and thanks a ton for cleaning up my code ;)

Avatar

Congratulations on 100 great tutorials. A really asset for the Rails community.

Avatar

Congratulations!!

Great work Ryan!!!

Avatar

Hi Ryan,

What do you use to create your screencasts and especially what software displays the keyboard shortcuts? It doesn't look like mouseposé.

Avatar

5 tips that really help in daily work!

Avatar

Congratulations Ryan! You really do some great work here. That contest is sick man, great move. I think its a great way to get people involved in the community. Keep em coming!

Avatar

Thanks a lot. You helped me much to learn RoR and to be productive with it..
Greetings from Germany

Avatar

Happy 100th anniversary !!!
thank you so much for doing this :)

Cheers from Switzerland

Avatar

Congratulations!!!

Avatar

Another concise and fun episode !!! Looking forward to your next 100 episodes. Thank you from Korea.