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?
Your application will only render the
rjsfiles 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 renderindex.rhtml.erbto produce the HTML response, which will in turn render_find.rhtml.erb. If some part of your page is requesting a script, then_find.rjswill be rendered (which actually just produces a javascript response behind the scenes). In this case,_find.rjsactually uses the HTML partial_find.rhtml.erbin the call toreplace_htmlto replace part of the page.BTW, you seem to be using an older version of Rails as
rhtmlandrjsare no longer used. I’d suggest working with a newer version.