I have a relationship like this
class User
include Mongoid::Document
include Mongoid::Timestamps
embeds_one :setting
end
and the setting class
class Setting
include Mongoid::Document
include Mongoid::Timestamps
embedded_in :user
field :notify, type: Boolean
end
and I have a form like this:
<% form_for current_user.setting || current_user.build_setting, :html => {:class => 'well'} do |f| %>
Notificar: <%= f.check_box :notify, :class => 'check' %>
<div class="form-actions">
<%= f.submit "Salvar" %>
</div>
<% end %>
but when I access the form page, the form isn’t shown. I suspect that it’s because setting is nil, or something like that…
What am I missing?
Thank you guys
You are missing an equal sign in front of
form_for.The
form_forhelper renders all the stuff in its block, adds a form tag and returns the html. In order to display it, you have to tell eRB you want to display the returned string. So when the equal sign is missing, it will just not display the output.