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
Answering my own mail (since nobody else does :-)> 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'', > ... > 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.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