jeudi 19 janvier 2017

Rails render partial from sub-directory

I've just implemented the Devise Invitable gem in my rails app and now I'm having an issue getting my partials to render. I imagine it's because of absolute vs. relative paths.

I'm hesitant to change much in my application.rb since all of my other views rely on the partials that are being rendered. So, is there another way to make this all work?

Here is the directory tree:

app/
 -controllers/
 ---application_controller.rb
 ---users/
 -----invitations_controller.rb
 -views/
 ---layouts/
 -----application.html.erb
 -----_back_buttons.html.erb
 -----_footer.html.erb
 -----_navigation.html.erb
 ---users/
 -----invitations/
 -------new.html.erb
 -------edit.html.erb

In my application.rb file, I'm currently rendering views & partials with:

<%= render partial: 'layouts/navigation' %>
<%= render partial: 'layouts/topnav' %>
<%= render partial: 'layouts/tour' %>

<%= yield %>

<%= render partial: 'layouts/footer' %>
<%= javascript_include_tag 'footermanifest' %>

And in my new view views/users/invitations/new.html.erb:

<%= render partial: "/layouts/back_button" %>
... the form

Notice the absolute reference to the partial here (/)

This loads the layouts/_back_button.html.erb fine, but none of the other partials in application.html.erb load. Basically, I have a pretty empty page with a form (courtesy of application.html.erb).

Am I doing something wrong in how I've nested the views/users/invitations/new.html.erb or something else?

Aucun commentaire:

Enregistrer un commentaire