Forum: Ruby on Rails select_month post and params

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.
5c087c6a1b61f6080ed2bc81787e0fbc?d=identicon&s=25 Andi Geheim (chaosbanane)
on 2008-11-22 11:19
Hi

why is that not working?


Controller-----------------------------------------------------

def bla

      month = params[:month_select]

      redirect_to :action => "index"
      flash[:error_messages_for] = month.to_s

end



View----------------------------------------------------------

<%form_tag :action => "bla" do %>

  <%= select_month(Date.today, :field_name => 'month_select') %>
  <%= submit_tag "Jump" %>

<% end %>

--------------------------------------------------------------

The notice is empty after the post.

Greetings, Andi
4dd8ed31b9effe2ee868e4cf78495c98?d=identicon&s=25 James Mitchell (Guest)
on 2008-11-22 16:18
(Received via mailing list)
The redirect should be the last statement.


On 11/22/08, Andi Geheim <rails-mailing-list@andreas-s.net> wrote:
>       month = params[:month_select]
> <%form_tag :action => "bla" do %>
> Greetings, Andi
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


--

--
James Mitchell
5c087c6a1b61f6080ed2bc81787e0fbc?d=identicon&s=25 Andi Geheim (chaosbanane)
on 2008-11-22 16:30
hi

thanks for the answer!

this is not the problem. The notice will be shown up on the index.

The problem is that the post is empty. If i exchange the select_month
with select_date the post work out.

for example:

I choose the date: 22.11.2008 the result is: month11day22year2008 (i am
not sure about the order)

Other ideas?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-22 17:26
(Received via mailing list)
On Nov 22, 3:30 pm, Andi Geheim <rails-mailing-l...@andreas-s.net>
wrote:
> hi
>
> thanks for the answer!
>
> this is not the problem. The notice will be shown up on the index.
>
> The problem is that the post is empty. If i exchange the select_month
> with select_date the post work out.

Check your logs to see under what name the parameter arrives (or look
at the rendered html)

Fred
5c087c6a1b61f6080ed2bc81787e0fbc?d=identicon&s=25 Andi Geheim (chaosbanane)
on 2008-11-22 17:44
> Check your logs to see under what name the parameter arrives (or look
> at the rendered html)

Where are those logfiles? in the rendered html it is correct i think:
name="date[month_select]"
5c087c6a1b61f6080ed2bc81787e0fbc?d=identicon&s=25 Andi Geheim (chaosbanane)
on 2008-11-22 18:26
Andi Geheim wrote:
>
>> Check your logs to see under what name the parameter arrives (or look
>> at the rendered html)
>
> Where are those logfiles? in the rendered html it is correct i think:
> name="date[month_select]"


Ah okay i know what logfile you mean :)

this is from this log:

"date"=>{"month_select"=>"11", "year_select"=>"2008"}

how can i params the month_select?
5c087c6a1b61f6080ed2bc81787e0fbc?d=identicon&s=25 Andi Geheim (chaosbanane)
on 2008-11-22 18:39
sorry for the soliloquy.

this is the solution:

<%= select_month(Date.today, :prefix => 'month_select', :field_name =>
'') %>

prefix is the right option -> params[:month_select]
the field_name option is an extension befor the name ->
if you select the november as month the value is field_name + month,
default is "month".

thanks and cya ;-)
This topic is locked and can not be replied to.