I have an html.erb file that does not render anything when the following is used:
<% form_for :profile do |form| %>
when this is used (note the “=” sign):
<%= form_for :profile do |form| %>
this is the output of the html:

Partial html code:
<%= form_for :profile do |form| %>
<%= text_field_for form, "first_name" %>
<%= text_field_for form, "last_name" %>
<div class="form_row">
<label for="gender">Gender:</label>
<%= radio_button :profile, :gender, "Male" %> Male
<%= radio_button :profile, :gender, "Female" %> Female
</div>
<div class="form_row">
<label for="birthdate">Birthdate:</label>
<%= date_select :profile, :birthdate,
:start_year => Profile::START_YEAR,
:end_year => Time.now.year,
:include_blank => true,
:order => [:month, :day, :year] %>
</div>
Form_for definition:
def text_field_for(form, field,
size=HTML_TEXT_FIELD_SIZE,
maxlength=DB_STRING_MAX_LENGTH)
label = content_tag("label", "#{field.humanize}:", :for => field)
form_field = form.text_field field, :size => size, :maxlength => maxlength
content_tag("div", "#{label} #{form_field}", :class => "form_row")
end
Part of controller:
def edit
@user = current_user
@user.profile ||= Profile.new
@profile = @user.profile
if param_posted?(:profile)
if @user.profile.update_attributes(params[:profile])
flash[:notice] = "Changes saved."
redirect_to :controller => "users", :action => "index"
end
end
end
In your
text_field_forhelper you need to declare that the string passed as the content of yourDIVtag generated by your helper is safe, and thus should not be sanitized. This is done withhtml_safe.