3

Hello guys so i have two namespaces, one nested inside another of the form

admin (namespace) inside admin i have blog (namespace)

i know that i can put the namespace like below in the form-for helper.

<%= form_for [:blog, @post] do |f| %>
  <%= render 'shared/error_messages', object: f.object %>
  <div class="large-12 columns">
    <div class="field panel">
      <%= f.label :title %><br>
      <%= f.text_field :title %>
    </div>

    <div class="field panel">
      <%= f.label :body %><br>
      <%= f.text_field :body %>
    </div>

    <div class="actions">
      <%= f.submit %>
      <%= link_to 'Back', admin_blog_posts_path %>
    </div>
  </div>

<% end %>

but how can i also prefix :admin namespace in front of that?

1 Answer 1

2

Found it.

for future reference

you just add a comma depending on the order of your namespaces

in the case above

<%= form_for [:admin,:blog, @post] do |f| %>
  <%= render 'shared/error_messages', object: f.object %>
  <div class="large-12 columns">
    <div class="field panel">
      <%= f.label :title %><br>
      <%= f.text_field :title %>
    </div>

    <div class="field panel">
      <%= f.label :body %><br>
      <%= f.text_field :body %>
    </div>

    <div class="actions">
      <%= f.submit %>
      <%= link_to 'Back', admin_blog_posts_path %>
    </div>
  </div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.