Forum: Ruby on Rails is this good for a conditional checkbox?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Josh K. (Guest)
on 2006-05-05 21:28
i'm pretty new to RoR and the MVC style of programming in general. i
have one page  with a list of applications that several users can
access. in my view, i have a conditional that decides whether the
checkbox is checked or unchecked. being new to this, i just did it the
only way i could think of and want to see if there's a better way of
accomplishing it.

selected_app = @user.apps.detect{ |app| == }
if selected_app
	is_checked = 'checked'
	is_checked = nil
	<td><%= %></td>
	<td><%= check_box 'add_app',, { :checked => is_checked },
'yes', 'no' %></td>
This topic is locked and can not be replied to.