Reputation: 351
I'm trying to understand foobar rails code and encountered following. There is controller A which inherits from controller B (A < B). And both of them don't have "index" method, but B has view "app/views/B/index.rhtml.erb" which will be rendered on that action from A controller. In that view there is line:
render(:partial => "find")
But there are two files: "app/views/A/_find.rhtml.erb" and "app/views/B/_find.rjs" And i can't understand which would be rendered if index was called from A controller. Further more "app/views/B/_find.rjs" has line:
page.replace_html(:contentBody, :partial => "find")
And i have no idea what is rendered here. Any ideas?
Upvotes: 0
Views: 60
Reputation: 11710
Your application will only render the rjs
files if a script was requested (usually through an AJAX request). If the user accesses your index action normally (i.e. a request for HTML using a browser), your app will render index.rhtml.erb
to produce the HTML response, which will in turn render _find.rhtml.erb
. If some part of your page is requesting a script, then _find.rjs
will be rendered (which actually just produces a javascript response behind the scenes). In this case, _find.rjs
actually uses the HTML partial _find.rhtml.erb
in the call to replace_html
to replace part of the page.
BTW, you seem to be using an older version of Rails as rhtml
and rjs
are no longer used. I'd suggest working with a newer version.
Upvotes: 1