0

I'm trying to customize a Rails Gem with the default CRUD-Views.

app/views/new.html.erb:

<div class="wishlist">
  <div class="row">
    <div class="small-12 medium-10 large-8 small-centered columns">

      <h1><%= Spree.t(:creating_wishlist) %></h1>
      <%= form_for @wishlist do |f| %>
      <p><%= f.label :name, Spree.t(:name) %>:&nbsp;<%= f.text_field :name %></p>
      <p><%= f.check_box :is_private %>&nbsp;<%= f.label :is_private, Spree.t(:is_private) %></p>
      <%= f.submit Spree.t(:create) %>
      <% end -%>

    </div>
  </div>
</div>

I want to avoid the same div containers .wishlist .row etc. in all the other views. How can i achieve something like:

# gem application layout:
<div class="wishlist">
  <div class="row">
    <div class="small-12 medium-10 large-8 small-centered columns">

      <%= yield %>

    </div>
  </div>
</div>

When i save it as app/views/layouts/application.html.erb and render it in the gem controller with layout 'application' then the view of the main Rails Application Layout will be overwritten. But I just want only the Gem CRUD views to get yield.

1 Answer 1

0

I could solve it with a partial that i render outside a do/end-block of the CRUD Views:

partial in app/views/base/_layout.html.erb

<div class="wishlist">
  <div class="row">
    <div class="hide-for-small medium-1 large-2 columns"></div>
    <div class="small-12 medium-10 large-8 small-centered columns">
      <%= yield %>
    </div>
    <div class="hide-for-small medium-1 large-2 columns"></div>
  </div>
</div>

and in my CRUD Views:

<%= render :layout => 'base/layout' do %>
  # content
<% end -%>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.