Need help making code more rails like!


#1

Hi all, I’ve been a PHP programmer for many years and I’ve recently
picked
up ruby and rails and am loving it! However, I’m still learning the
“rails
way” of doing things and I’ve got a block of code that I think could use
a
face lift. Any help, tips, suggestions, you can offer in making it more
rails-like is greatly appreciated. The only thing that I need for sure
is
the call to check_box_tag(). Thanks in advance for any assistance!

The following code is contained within a partial (excuse the formatting
mess):

<% for course in @courses -%>
<%= course.name %>:
<% if course.id.to_s == session[:current_course].to_s -%>
<%= check_box_tag ‘post_courses[]’, course.id, true,
{:disabled
=> ‘disabled’} %>

<% else -%>
<%= check_box_tag ‘post_courses[]’, course.id %>

<% end -%>
<% end -%>