Forum: Ruby on Rails Multi-parameter assignment

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.
3bdb0e723531e44040fe7131f723ef0b?d=identicon&s=25 Mark Paxton (mpaxton)
on 2006-04-15 04:27
Hi,

I'm trying to submit data from text boxes on a form to one variable in
my controller, in the same way that datetime_select has date(1i),
date(2i), etc for day, month, year, etc...

I've named my variables event[start_date(1i)] event[start_date(2i)] and
event[start_date(3i)] but this doesn't seem to work and
event[:start_date] is blank ... any pointers would be useful!  Can't
seem to find any docs for this!

Cheers,
Mark
A111108ed3617edc35da89e84689c3c2?d=identicon&s=25 Arch Stanton (d6veteran)
on 2006-04-15 05:45
Mark Paxton wrote:
> Hi,
>
> I'm trying to submit data from text boxes on a form to one variable in
> my controller, in the same way that datetime_select has date(1i),
> date(2i), etc for day, month, year, etc...
>
> I've named my variables event[start_date(1i)] event[start_date(2i)] and
> event[start_date(3i)] but this doesn't seem to work and
> event[:start_date] is blank ... any pointers would be useful!  Can't
> seem to find any docs for this!
>
> Cheers,
> Mark

Can you post a code snippet?
3bdb0e723531e44040fe7131f723ef0b?d=identicon&s=25 Mark Paxton (mpaxton)
on 2006-04-15 23:28
Arch Stanton wrote:
> Mark Paxton wrote:
>> Hi,
>>
>> I'm trying to submit data from text boxes on a form to one variable in
>> my controller, in the same way that datetime_select has date(1i),
>> date(2i), etc for day, month, year, etc...
>>
>> I've named my variables event[start_date(1i)] event[start_date(2i)] and
>> event[start_date(3i)] but this doesn't seem to work and
>> event[:start_date] is blank ... any pointers would be useful!  Can't
>> seem to find any docs for this!
>>
>> Cheers,
>> Mark
>
> Can you post a code snippet?

I've had a play around, so I'll try and explain properly:

On my form I have:
<input id="eventdetail[start_time_date]"
name="eventdetail[start_time(1)]" size="8" type="text"
value="15/04/2006" />
<input id="eventdetail[start_time(2)]" name="eventdetail[start_time(2)]"
type="hidden" value=" " />
<input id="eventdetail[start_time_time]"
name="eventdetail[start_time(3)]" size="8" type="text" value="21:46" />

I intend for this to end up in my controller as:
eventdetail[:start_time] = "15/04/2006" + " " + "21:46"
Which can then be validated on save.

It doesn't seem to work that way, as start_time is not assigned after
the form is submitted but only when I do:
@eventdetail = Eventdetail.new(@params[:eventdetail])

Which gives me an error:
1 error(s) on assignment of multiparameter attributes

I understand this would be trying to do Date.new("15/04/2006", " ",
"21:46") which is wrong, so the real question is, is it possible to
automatically get start_time to just end up as the one string I can work
with?

Cheers,
Mark
This topic is locked and can not be replied to.