Well, it even got worse, but I figured it out.
forgot about http://guides.rubyonrails.org/layouts_and_rendering.html
If there were 5 items in the list, the template would be rendered 5
time!
I am not sure why I could not get render(:partial => "stages/
applicants") to work yesterday, must have been typo''s or
something,
but I got it to work today. I did have to use the view folder before
the partial name.
Steve
On Dec 5, 4:28 pm, AppleII717 <sa...-ee4meeAH724@public.gmane.org>
wrote:> Some things seem like they will never be clear with Rails. It took me
> half a day to figure out how to render a partial using unobtrusive js,
> but it is not clear why it works and why it went through all the
> singular plural stuff.
>
> In the show view of a model, I wanted to display two related lists/
> indexes (with a :remote => true link to load them). One of the items
> has a controller, but I normally just create a partial to display the
> list because all the features in the index view may not apply. The
> other item does not have a controller and lives within its parent
> model.
>
> the routes:
> resources :stages do
> resources :assessors, :only => [:index, :new, :create]
> member do
> get "import"
> get "applicants"
> end
> end
>
> Applicants live only with stages and are dynamically created/updated.
>
> Following the Railscast on unobtrusive JS and trying to turn it into
> something that would load a partial, nothing seemed to work. I could
> not access my _applicants.html.erb with js, it wanted it in the
> assessors view. I finally got an error on the log that said, not only
> does it want it in the assessors view directory, it wants it named
> _assessor - even thought it is a list.
>
> Same thing with the applicants. It would take the applicants.js.erb
> file in the stages directory, but wanted a singular partial in the
> applicants view - which I did not have.
>
> The JS line is:
>
> $("related").update("<%=
escape_javascript(render(@applicants))%>");
>
> The render call won''t accept partial, file name or about anything
else
> I tried.
>
> I know there is not a lot out there yet on rails3 and unobtrusive JS,
> but if someone could enlighten me, I''d appreciate it.
>
> Steve
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.