Ross,
Yes, I understand the controller/view paradigm, but why do I need the
_get_reordered_images file in my example?
Anyway, back to your issue. The reason I detailed my solution, was
because the error message you received, is one I have gotten and it was
very frustrating. I, too, was able to get some things to happen one
way, but when I tried a different way, I had the pieces not quite right.
When you say the “ability” to call a method is disappearing, I’m
guessing that you probably are not really “calling” the method when you
think you are or that it doesn’t exist when you think it does.
For example, you said you moved the code into the controller and it
couldn’t find the method. Aren’t methods just for classes? If not,
isn’t it funny that you cannot evoke it when it’s in the controller?
I couldn’t “invoke” my get_reordered_images either until I rendered it
“twice”, once in my index file:
<%= render(:partial => ‘get_reordered_images’) %>
and then again in my _get_reordered_images file.rhtml:
<%= render_component(:action => ‘get_reordered_images’) %>
even though the get_reordered_images action (module, method?) was in my
controller file and worked when I used:
<%= render(:partial => ‘form’) %>
and called it from _form.rhtml.
Again, I feel your frustration and thought another example may give you
a nugget of insight that helps you figure out why the method appears to
disappear.
Good luck!
Ross Ashley wrote:
David T-L wrote:
I believe if you are using <%= render(:partial =>
‘get_reordered_images’) %> in your index.rhtml file, you also then need
to have a file called _get_reordered_images in your index.rhtml folder
with the following code:
<%= render_component(:action => ‘get_reordered_images’) %>
This code then miraculously does what I thought the original index.rhtml
code would do and, in my case, calls the “action” in my controller.rb
file called get_reordered_images.
Well I think the paradigm is that the controller performs some action
and then renders a view. So unless you specifically call an action back
in your controller, which is what render_component does, you won’t get
back to controller code without an action by the user.
However, that is a different problem than the one below.