Forum: Ruby on Rails Best RJS process for what I'm trying to do...

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Curtis E. (Guest)
on 2006-04-10 01:34
(Received via mailing list)
I just wanted to ping this off the list to get some advice since I'm
now pulling my hair out. Thanks in advance for taking any time to look
at this. It's much appreciated. Now, my problem is my RJS is working
but it's not inserting how I want it to insert. I have a partial I'm
rendering in my view that looks like this:

<ul id="meal_names">id="meal_names">

<% @meal_names.each do |item| -%>

<li><b><%= %></b> <font size="0"><%= link_to "delete", {
:controller => 'meal_names', :action => 'destroy', :id =>},
:confirm => "are you sure you want to delete #{}?"
%></font></li>do |item| -%>

<li><b><%= %></b> <font size="0"><%= link_to "delete", {
:controller => 'meal_names', :action => 'destroy', :id =>},
:confirm => "are you sure you want to delete #{}?"
%></font></li><li><b><%= %></b> <font size="0"><%= link_to
"delete", { :controller => 'meal_names', :action => 'destroy', :id =>}, :confirm => "are you sure you want to delete #{}?"

<% end %>end %>


and this does give me a list of names but when i submit a new name, it
gets added to the list as just

<li> #{}   </li>

so it doesn't have the formatting or the delete button like the other
items. Whenm I refresh the page, then it looks proper. Here's my
controller add method:

 def add

 @name = MealName.create( params[:meal_name] )
  @meal_names = MealName.find(:all)
  @meal_names << @name
 render :update do |page|
   page.insert_html :bottom, 'meal_names', "<li> #{}   </li>"
   page.visual_effect :highlight, 'meal_names', :duration => 3


I thought I could get around this by doing a @meal_names << @name and
that didn't work. I'm thinking I'm just not doing this properly. Help!
Kevin O. (Guest)
on 2006-04-10 02:26
(Received via mailing list)
Your RJS template is doing exactly what you told it to.
If you want all the other link stuff, you have to add it.
I suggest creating a partial that does all the formatting you want for
each item and then insert that partial to the end of meal_names.

On Sunday, April 09, 2006, at 3:32 PM, Curtis E. wrote:
>}, :confirm => "are you sure you want to delete #{}?"
>  @meal_names << @name
>Rails mailing list

This topic is locked and can not be replied to.