Forum: Ruby on Rails using form_remote_tag and radio_button

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.
B8d11b4c89cfc6e34d6c9fb121c9acac?d=identicon&s=25 Claus Guttesen (Guest)
on 2006-04-05 01:04
(Received via mailing list)
I want the user to select a date using radio buttons. The following
code shows the last 7 days.

<%= form_remote_tag(:update => 'register_order',
                    :url => { :action => :register_orders } ) %>
  <% 1.upto(7) do |i| %>
    <%= radio_button "date", "register_date",
i.days.ago.strftime("%Y-%m-%d") %>
             <%= i.days.ago.strftime("%Y-%m-%d") %>
    <br />
  <% end %>
    <br />
  <%= submit_tag "Register" %>
<%= end_form_tag %>
<div id="register_order"></div>

The controller has:

  def register_orders
    render(:layout => false)
    @date = params[:date][:register_date]
  end

register_orders.rhtml has:

Date:  <%= @date %>

If I comment out render-layout I get the date in
register_orders.rhtml, but also the layout twice. If I activate
render-layout I can get the date by changing register_orders in the
controller to:

  def register_orders
    render(:layout => false)
    render_text params[:date][:register_date]
  end

But then register_orders.rhtml appears unused. Am I missing something?
This is on rails 1.0, webrick, os x.

regards
Claus
B8d11b4c89cfc6e34d6c9fb121c9acac?d=identicon&s=25 Claus Guttesen (Guest)
on 2006-04-05 10:03
(Received via mailing list)
Answering my own mail (since nobody else does :-)

> register_orders.rhtml, but also the layout twice. If I activate
> render-layout I can get the date by changing register_orders in the
> controller to:
>
>   def register_orders
>     render(:layout => false)
>     render_text params[:date][:register_date]
>   end
>
> But then register_orders.rhtml appears unused. Am I missing something?
> This is on rails 1.0, webrick, os x.

Turns out that I had to change register_orders in the controller to:

  def register_orders
    #render(:layout => false)
    @date = params[:date][:register_date]
    render :partial => "register_orders"
  end

So render partial solved the problem. Rendering partials also requires
a rename to _register_orders.rhtml.

regards
Claus
This topic is locked and can not be replied to.