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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On 12/19/06, Bala Paranj <bcparanj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You call the partial the same way from two views, and you are wondering how to call the partial form the third view? Seems like a silly question. Just use the same cope snippets used the first two times. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On 12/20/06, Alex Wayne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > You call the partial the same way from two views, and you are wondering > how to call the partial form the third view? > > Seems like a silly question. Just use the same cope snippets used the > first two times. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bala Paranj wrote:> 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.Are you trying to create a new partial for show.rhtml and not re-use the _profile.rhtml? If so, It super easy and works fine with the h() method #show.rhtml <h1>Some html</h1> <%= render :partial => ''some_other_stuff'', :locals => {:foo => @foo} %> #_some_other_stuff.rhtml <%=h foo.title %> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On 12/21/06, Alex Wayne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Bala Paranj wrote: > > 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. > > Are you trying to create a new partial for show.rhtml and not re-use the > _profile.rhtml? > > If so, It super easy and works fine with the h() method > > #show.rhtml > <h1>Some html</h1> > <%= render :partial => ''some_other_stuff'', :locals => {:foo => @foo} > %> > > #_some_other_stuff.rhtml > <%=h foo.title %> > > -- > Posted via http://www.ruby-forum.com/. > > > >-- ------------------------------- Jorge Sousa --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---