Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i render :partial a view without leading underscore?

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

like image 507
ZX12R Avatar asked May 12 '10 12:05

ZX12R


People also ask

How do you render a partial?

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() .

What is render partial rails?

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.

What is render partial in Ruby?

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.


2 Answers

<%= render :file => '/homes/contact' %> 
like image 107
fl00r Avatar answered Sep 27 '22 18:09

fl00r


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' %> 
like image 30
ericteubert Avatar answered Sep 27 '22 18:09

ericteubert