Partials Question

I have a partial called _profile.html:

<p>
   <b>Name</b><br />
   <%= f.text_field :name %>
</p>
<p>
   <b>Email</b><br />
   <%= f.text_field :email %>
</p>
<p>
.....

edit.rhtml is using the partial as follows:

<h1> Edit Your Billing Profile </h1>
<%= error_messages_for :billing_profile %>
<% form_for :billing_profile, @bp, :url =>
billing_profile_path(@billing_profile), :html => { :method => :put }
do |f| %>

<%= render :partial => "profile", :locals => { :f => f } %>
  <p>
    <%= submit_tag "Update" %>
  </p>
<% end %>

<%= link_to 'Show', billing_profile_path(@bp) %> |
<%= link_to 'Back', billing_profiles_path %>

and new.rhtml is using it as follows:

<h1>New billing_profile</h1>

<%= error_messages_for :billing_profile %>
<% form_for(:billing_profile, :url => billing_profiles_path) do |f| %>

  <%= render :partial => "profile", :locals => { :f => f } %>
  <p>
    <%= submit_tag "Create" %>
  </p>
<% end %>

<%= link_to 'Back', billing_profiles_path %>

My question is how do I use partials for show.rhtml? I used the
scaffold generator of Rails 1.2 and it looks like:

<p>
  <b>Email:</b>
  <%=h @billing_profile.email %>
</p>

<p>
  <b>Business phone:</b>
  <%=h @billing_profile.business_phone %>
</p>
......
<%= link_to 'Edit', edit_billing_profile_path(@billing_profile) %> |
<%= link_to 'Back', billing_profiles_path %>

I tried several things but it breaks the functional tests. TIA.

Hi, what error message are you seeing? Please provide the relevant
output from the log as well as the functional test that you're
running.

Thanks,

-Conrad

There is a difference. The partial differs from the generated scaffold because the scaffold has the “h” function that sanitizes the input.

So I don’t think it is possible to use the partial in this case.

Sorry, but it to me it doesn’t make sense if what you want is turn the show.rhtml into a partial, go ahead and do what Alex suggests.

if you want to use the existing _profile partial whats the point?

that partial contains input fields that are shared between 2 forms. its a DRY applied to form’s content. Two form views that share the same input controls.

On the show view you’ll probably want to output or “show” existing data so why use input fields to accomplish that? you’ll be GETing data not POSTing nothing.

right?

Jorge