Leonardo Mateo wrote:
> On Tue, Oct 20, 2009 at 8:17 AM, Francesco Belladonna
> <[email protected]> wrote:
>>>
>>> --
>> creates html tags formatted in a way, so the day selection tag will have
>> "name" attribute "calendar[mydate(3i)]", the month will have
>> "calendar[mydate(2i)]" and so on. If I change these tags in my single
>> text field tag I will have "calendar[mydate]" and nothing else, but when
>> I send this information obviusly ruby should understand how to "split"
>> this date to store it: where should I do this (and where could I read my
>> submitted vars?)? In controller I only have
>> Calendar.new(params[:calendar]) in create method, so I think that params
>> should be "changed" in some way, is this the good way?
> 
> Yes, I don't think there's any other way to do that. You should parse
> your params[:calendar][:mydateXX] and format them in the way you need.
> I would do something like:
> day = params[:calendar] .delete("mydate(3i)")
> month = params[:calendar] .delete("mydate(3i)")
> year = params[:calendar] .delete("mydate(3i)")
> #I don't really remember the order they are stored, but you get the idea
> Then, do somehting like:
> params[:calendar][:name_of_the_date_field_here] = Date.new(year, month, 
> day)
> And then:
> Calendar.new(params[:calendar]
> 
> But that's just my first approach to this, maybe you can figure out a
> better way to do it.
> 
> Hope it helps.
> 
> 
> --
> Leonardo Mateo.
> There's no place like ~

Thanks your suggestion actually is working for me (and better: I've 
understood it)

theambler wrote:
> I found this helpful:
> 
> http://railscasts.com/episodes/73-complex-forms-part-1
> 
> and the two episodes that follow.

These seems even better, but actually I have some difficults in 
understanding it (I'm at the very beginning, so I'm having troubles in 
understanding some processes)
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to