user2164011
user2164011

Reputation:

Difference between render :template and render :partial in rails 3

i was a bit experimenting in my rails app.i tried to use render :template in erb file .i got an error.After that i changed it to render :partial and it ran successfully as i was expecting.i am wondering why i got this error.i tried to google but i got no major source that points out the difference between the two.Does the two behave differently at controller level and view level.if yes then why?

Upvotes: 3

Views: 2916

Answers (1)

MechDog
MechDog

Reputation: 548

The render :partial looks for the file name to be proceeded by an underscore while the template does not:

  render partial:'example'

looks for _example.html.erb

while:

 render template: 'example'

looks for example.html.erb

There may be other issues, but odds are this is why you recieved the error based on it working once you made the change. Hope this helps...

Upvotes: 4

Related Questions