Forum: Ruby on Rails Up-dates

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0a36dd2d45a8cead5dcfd27a9346f620?d=identicon&s=25 Mohammad (Guest)
on 2006-04-28 00:58
I started working on a chat program but, I'm having this problem

chatroom.rhtml
<div id="chatroom">
</div>
<%= periodically_call_remote( :update => "chatroom",
                              :url    => {:action => :chat },
                              :frequency => 2) %>

chat.rhtml
<h1><%= @chat.room %> room.</h1>
<table border="5" bordercolor="darkred">
<tr><td><pre><%=h @chat.chat %></pre></td></tr>
</table>

but, when I call chatroom it dosn't work but chat does, what is the
problem here?
0a36dd2d45a8cead5dcfd27a9346f620?d=identicon&s=25 Mohammad (Guest)
on 2006-04-28 05:44
Mohammad wrote:
> I started working on a chat program but, I'm having this problem
>
> chatroom.rhtml
> <div id="chatroom">
> </div>
> <%= periodically_call_remote( :update => "chatroom",
>                               :url    => {:action => :chat },
>                               :frequency => 2) %>
>
> chat.rhtml
> <h1><%= @chat.room %> room.</h1>
> <table border="5" bordercolor="darkred">
> <tr><td><pre><%=h @chat.chat %></pre></td></tr>
> </table>
>
> but, when I call chatroom it dosn't work but chat does, what is the
> problem here?

Can anyone help me with this I have to have my project done this week.
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-04-28 13:04
(Received via mailing list)
Mohammad wrote:
>>
> Can anyone help me with this I have to have my project done this week.
>

What does your chatroom action look like?
2d1a6a800524db3dd5a6bd7c79ea0e7b?d=identicon&s=25 Peter (Guest)
on 2006-04-28 13:52
loose :update in youre call and set an actual <div> to
update the contents in youre controller.

def chat
  @data = something
  render :update do |page|
      page.replace_html 'new', @data
  end
end

now 'new' is a <div> in youre chat.rhtml file with an id='new'
or something more descriptive of course
0a36dd2d45a8cead5dcfd27a9346f620?d=identicon&s=25 Mohammad (Guest)
on 2006-04-28 15:19
I did what you said Peter but look at this,
try {
Element.update("data", "<h1>Welcome to chatroom
Service</h1><br><br><table border='2'><tr><td>Reminder: Please make sure
the awnser is not in the \"FAQ\":/questions\r\nHaroon: I need help, my
mail for actavation isn't going out.\r\nAdmin: For *strong* secuirty we
must ask you a couple of questions.\r\nHaroon: Okay.\r\nAdmin: On your
contract it says \"ID #??\"\r\nHaroon: 982731\r\nAdmin: Your
name.\r\nHaroon: Haroon.\r\nAdmin: Secuirty word:\r\nHarron: *Password
has been blocked by admin*\r\nAdmin: Thank you, I will now look into
it.</td></tr></table>");
} catch (e) { alert('RJS error:\n\n' + e.toString());
alert('Element.update(\"data\", \"<h1>Welcome to chatroom
Service</h1><br><br><table border=\'2\'><tr><td>Reminder: Please make
sure the awnser is not in the \\"FAQ\\":/questions\r\nHaroon: I need
help, my mail for actavation isn\'t going out.\r\nAdmin: For *strong*
secuirty we must ask you a couple of questions.\r\nHaroon:
Okay.\r\nAdmin: On your contract it says \\"ID #??\\"\r\nHaroon:
982731\r\nAdmin: Your name.\r\nHaroon: Haroon.\r\nAdmin: Secuirty
word:\r\nHarron: *Password has been blocked by admin*\r\nAdmin: Thank
you, I will now look into it.</td></tr></table>\");'); throw e }


Thats what it show. Any clue what that means? Why is it not doing the
HTML? Here is what my controller looks like:


def chat
  @chat = Chat.find(:first)
  @data = RedCloth.new(I have done with and without this still the same)
"<h1>Welcome to chatroom " + @chat.room + "</h1><br><br><table
border='2'><tr><td>" + @chat.chat + "</td></tr></table>"
  render :update do |page|
      page.replace_html 'data', @data
  end
end

And here is my rhtml file.

<div id="data">
</div>

Any clues?
This topic is locked and can not be replied to.