Hugo
Hugo

Reputation: 2444

rails partial not found but it exists

inb4 read the docs

I've already tried everything in the documentation and everything on stackoverflow just repeats the documentation.

I'm trying to render a partial from within another view inside a gem being used by the application:

<%= render :partial => "#{Rails.root.to_s}/app/views/layouts/login" %>

It's complaining that the partial isn't found even though I know it exists.

Missing partial /home/hstorres/src/<app-name>/app/views/layouts/login

The following command was done from within the app containing the partial:

$ ls /home/hstorres/src/<app-name>/app/views/layouts
application.html.erb _login.html.erb

So if it exists, and it's looking for it in the right place, why can't it find it?

Upvotes: 0

Views: 1907

Answers (3)

kid_drew
kid_drew

Reputation: 3995

View paths in Rails are relative to /app/views/. Simply typing render :partial => "layouts/login" will do what you want.

Upvotes: 0

cionescu
cionescu

Reputation: 144

You could use

<%= render "layouts/login" %>

Upvotes: 0

Sanket
Sanket

Reputation: 490

Please try this

<%= render :partial => "layouts/login" %>

Upvotes: 1

Related Questions