Paritosh Singh
Paritosh Singh

Reputation: 6384

Use rails engine partial within application

I am using a rails mountable engine called 'Child' inside the application called 'Parent'.

I have a partial 'child/user/_index.html.erb'

Now I want to render this child's partial in parent controller. Is it possible?

Means I want to do something like

render :partial => 'child/user/index.html.erb'

Thanks

Upvotes: 4

Views: 3128

Answers (3)

Nimir
Nimir

Reputation: 5839

This what worked for me:

render file: 'child/user/_index.html.erb'

Upvotes: 0

why
why

Reputation: 24851

I think you can just render user/index

ref http://edgeguides.rubyonrails.org/engines.html

The engine is unable to find the partial required for rendering the comments. Rails looks first in the application's (test/dummy) app/views directory and then in the engine's app/views directory. When it can't find it, it will throw this error. The engine knows to look for blorgh/comments/comment because the model object it is receiving is from the Blorgh::Comment class.

Upvotes: 0

Salil
Salil

Reputation: 47482

Ref this

render :file => 'child/user/index.html.erb' 
###or try '/child/user/index.html.erb'

Upvotes: 4

Related Questions