I’m using Rails 1.1.x and it looks like the check_box form helper
expects me to provide and object and method so it can determine if the
checkbox should be checked or not. I’m having a couple of issues with
this.
note: I’m using UserEngine and adding a HABTM so that:
class User < ActiveRecord::Base
has_and_belongs_to_many :foos
end
class foo < ActiveRecord::Base
has_and_belongs_to_many :users
def attached?(user = session[:user])
return false unless users.find(user.id)
end
end
and in my .rhtml I have this:
<% for foo in @foos %>
<%= check_box foo, attached? %>
<% end %>
Even if I verify in the console that the current user is in foo’s user
array, I never get a checked value in my form.
- I can’t see to tell if foo.attached? is being called
- If I try and explicitly call foo.attached? in the .rhtml, I get an
exception that in the call of attached?, user is nil. So it’s almost
like session[:user] isn’t in scope during the call. That seems odd,
too. - Should I dump the helper and write my own .rhtml to render the form?
If so, I run into (2) again because user is nil
Thoughts?
–dwf