Forum: Ruby on Rails Why isn't this working?

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.
17fefeb3c1832175bf6fbe9841368292?d=identicon&s=25 mbonig (Guest)
on 2005-12-01 05:35
(Received via mailing list)
Ok, so I know this is a totally obvious question, but it's dumbfounding
me
right now. I've got Ruby on Rails going and I know this has worked
before...

I have a html fragment that does:
---
<%= link_to_remote (h('<Description>'),
						:id => '1',
						:update => 'todo_display',
						:url => { :action => :render_todo_display }) %>
---


This is the code in the same controller:
---
def render_todo_display
		render(:layout => false)
		@par = @params["id"]
end
---

and this is the .rhtml file:
---
just somethign</br>
<%= @par %>
just somethign else</br>
---

But when I click on the link in the html fragment, the correct section
gets
updated with just this:
---
just somethign
just somethign else
---

I've tried:
@par = params[:id]

that didn't work. I know this is totally easy, but what the heck is
wrong?
132a94ca65959bda6c74fae54bff2425?d=identicon&s=25 ezra (Guest)
on 2005-12-01 07:28
(Received via mailing list)
On Nov 30, 2005, at 8:31 PM, Matthew Bonig wrote:

> ---
>
>
> This is the code in the same controller:
> ---
> def render_todo_display
> 		render(:layout => false)
> 		@par = @params["id"]
> end
def render_todo_display
      @par = @params["id"]
      render :layout => false
end

You need to set the var before you render ;)
> section gets updated with just this:
>
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

-Ezra Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra@yakima-herald.com
509-577-7732
953c18019bceaa294ae0429bef6ab388?d=identicon&s=25 norman (Guest)
on 2005-12-01 10:51
(Received via mailing list)
Am Mittwoch, den 30.11.2005, 22:23 -0800 schrieb Ezra Zygmuntowicz:
> > 						:update => 'todo_display',
> > 						:url => { :action => :render_todo_display }) %>
> > ---
> >

You have also to put the :id key into the :url hash if you want to
retrieve it in your controller action.

<%= link_to_remote (h('<Description>'),
	:update => 'todo_display',
	:url => { :action => :render_todo_display, :id => '1' }) %>
This topic is locked and can not be replied to.