0
votes

I have two different folders in View folder, lets say them A and B.

In B folder, the content is generated by scaffold, so there is 5 html.erb files inside: _form.html.erb, edit.html.erb, index.html.erb, new.html.erb and show.html.erb.

What I need is only index.html.erb, edit.html.erb and _form.html.erb, which is because users are only allowed to edit the content and do nothing else.

In A folder, I have only 1 index.html.erb, and I want everything shows on this file. How to render the index and form file to it? I want users could see the content of index.html.erb and they can also click 'edit' to go to the form.html.erb. And the form should be in my A folder's index file, too..

3
@RajeshCO Sorry! my bad! I need edit.html.erb. - user2049259
In folder A's index.html file you want folder's B index & form file ...right ? - LHH
@LHH yes,sir. I want the B index file's content appear on A's index.html file, maybe in a div, so the existed content in A's index.html file will not be affected. - user2049259
and what about B's form file ? - LHH
Please check my answer below - LHH

3 Answers

1
votes

You can simply do this in Folder A / index.html.erb

<div>
  <%= render 'B/form' %>
</div>
<div>
  <%= render template: 'B/index' %>
</div>

Now these files will be rendered in folder's A index file

0
votes

From what you've written, it seems you may benefit from prepend_view_path:

#app/controllers/b_controller.rb
Class BController < ApplicationController
   before_filter :set_path
   private
   def set_path
      self.prepend_view_path "app/views/controller-a/"
   end
end