View another controller

What I want to do is to have 2 different controllers, a client and test_client. The client controller is already built, and I want to create a test_client controller, which I can use to interact with the client user interface and adjust it if necessary. I am basically trying to get around the check I built in to the client and its dependency on the admin controller that loads the data.

so I want the test_client controller to load the sample data and then display the index representation of the client controller so that I can customize the client user interface. It's all.

I tried this in the index_clients method:

class TestClient
    def index
        render :template => 'client/index'
    end
end

but I get an error because he cannot find partial parts of the client, because he is looking for the current controllers for them ...

So, I already studied this, and most people say that you should never make such a call, but I think this case is a wise use ... I just need to figure out how to make it work.

+5
source share
3 answers

You will need to adjust your presentation so that the path to the part you need is in shape 'controller/partial'. In this case it’s possible 'client/partial'. Then you can just use render 'client/index'it as before.

So say somewhere in your view that you have this:

<%= render :partial => 'info' %>

You want to change it to this:

<%= render :partial => 'client/info' %>
+6

, test_client, test_client.

:

index.html.erb _index.html.erb

test_client
index.html.erb
  <% = render: partial = > 'clients/index',: locals = > {}% >

+2

, . , , , . false.

Then, in the client_test view, you can display this index along with the host associated with it.

0
source

All Articles