i am facing a precarious condition here. I need to partially render a page that does not have a leading underscore.
<%= render(:partial => "contact" ,:controller=>"home") %>
this will look for
app/views/home/_contact.html.erb
but i want it to look for
app/views/home/contact.html.erb
is there a way of doing this.?
Thanks
Rendering a Partial View You can render the partial view in the parent view using the HTML helper methods: @html. Partial() , @html. RenderPartial() , and @html. RenderAction() .
Rails Guides describes partials this way: Partial templates - usually just called "partials" - are another device for breaking the rendering process into more manageable chunks. With a partial, you can move the code for rendering a particular piece of a response to its own file.
Ruby on Rails Views Partials Partial templates (partials) are a way of breaking the rendering process into more manageable chunks. Partials allow you to extract pieces of code from your templates to separate files and also reuse them throughout your templates.
<%= render :file => '/homes/contact' %>
You should not try to bypass the conventions if not really necessary. I guess contact.html.erb contains a form. Put this into app/views/home/_contact.html.erb
and render it in app/views/home/contact.html.erb
.
Or as fl00r answered:
<%= render :file => '/homes/contact' %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With