[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Getting a field value in a form with ruby

Mark Mr

3/3/2008 9:49:00 PM

Hi guys. I have a form to submit an assessment for one of my web apps.
The model contains a datetime field called ends_at which is when the
assessment is supposed to end. Before, I had a datetime_select field for
this, but I put in a calendar popup to do the date for them. However, I
also need them to choose the time as well so this is initially what i
came up with

<%= date_field 'assessment', 'ends_at', :value => "Click here..." %>
<%= time_select 'assessment', 'ends_at'%>

But unfortunately this replaces the date they selected with today's date
because it discards the first date field after it reads the time one.
Basically i want to know if there's a way to somehow combine the date
and the time fields in the form and perhaps pass them in a hidden field
to the controller. I don't know how to interact with the values inside
fields before they're submitted. Or if anyone has another suggestion on
how to make that work I'd take that too :) thanks alot!
--
Posted via http://www.ruby-....

6 Answers

Avdi Grimm

3/3/2008 9:57:00 PM

0

On Mon, Mar 3, 2008 at 4:49 PM, Mark Mr <pimea.mark@gmail.com> wrote:
> Or if anyone has another suggestion

I do... ask the Rails mailing list:
http://groups.google.com/group/rubyon.... This is the Ruby
Language ML.

On your actual problem - why do both fields have to have the same
name? Can't one be ends_at_date and the other be ends_at_time? And
if they really must have the same name, try adding empty brackets
after the method name: date_field 'assessment', 'ends_at[]'. Then
both values will come back in an array.

--
Avdi

Craig Demyanovich

3/3/2008 10:03:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

Hi,

I agree that you should take this to the Rails mailing list.

Here's another idea to play with, though.

Give each field a distinct name, e.g., assessment_end_date and
assessment_end_time. When the form is submitted, combine them. Here's a
rudimentary way it could be done:

assessment.end_at = DateTime.parse("#{params[assessment_end_date]}
#{params[assessment_end_time]}")

Good luck,
Craig

Mark Mr

3/3/2008 10:40:00 PM

0

Ok I'll try that google group then. The fields are the same name because
that's the name of my field in the assessments database. I could split
it up into 2 fields in my database but I was just wondering if there's a
way to just combine the 2 values so I can put them in that ends_at
field. Thanks though.
--
Posted via http://www.ruby-....

Avdi Grimm

3/3/2008 10:51:00 PM

0

On Mon, Mar 3, 2008 at 5:39 PM, Mark Mr <pimea.mark@gmail.com> wrote:
> Ok I'll try that google group then. The fields are the same name because
> that's the name of my field in the assessments database. I could split
> it up into 2 fields in my database but I was just wondering if there's a
> way to just combine the 2 values so I can put them in that ends_at
> field. Thanks though.

I suggest you dig into the documentation for the composed_of flag to
ActiveRecord associations. It might give you just the solution you're
looking for.

--
Avdi

Dano

2/23/2014 5:16:00 PM

0

"David Johnston" wrote in message news:lecaup$jfv$1@dont-email.me...

On 2/20/2014 10:06 AM, Adam H. Kerman wrote:
> Irish Mike <ad7cb8d@webnntp.invalid> wrote:
>
>> This is an Incredible story!
>
>> In 1986, Peter Davies was on holiday in Kenya after graduating from
>> Northwestern University . On a hike through the bush, he came across a
>> young bull elephant standing with one leg raised in the air.
>
>> The elephant seemed distressed, so Peter approached it very carefully.
>> He got down on one knee, inspected the elephants foot, and found a large
>> piece of wood deeply embedded in it.
>
>> As carefully and as gently as he could, Peter worked the wood out with
>> his
>> knife, after which the elephant gingerly put down its foot.
>> The elephant turned to face the man, and with a rather curious look on
>> its
>> face, stared at him for several tense moments..
>
>> Peter stood frozen, thinking of nothing else but being trampled.
>> Eventually the elephant trumpeted loudly, turned, and walked away.
>> Peter never forgot that elephant or the events of that day.
>
>> Twenty years later, Peter was walking through the Chicago Zoo with his
>> teen aged son. As they approached the elephant enclosure, one of the
>> creatures turned and
>> walked over to near where Peter and his son Cameron were standing.
>
>> The large bull elephant stared at Peter, lifted its front foot off the
>> ground, then put it down. The elephant did that several times then
>> trumpeted loudly, all the while staring at the man.
>
>> Remembering the encounter in 1986, Peter could not help wondering if this
>> was the same elephant. Peter summoned up his courage, climbed over the
>> railing, and made his way into the enclosure.
>
>> He walked right up to the elephant and stared back in wonder.
>> The elephant trumpeted again, wrapped its trunk around one of Peter legs
>> and slammed him against the railing, killing him instantly.
>
>> Probably wasn't the same elephant..
>
> You'd think I'd have heard of "Chicago Zoo" or read this story in 2006.
> Odd. The zoos I'm familiar with built moats around elephant enclosures,
> so there's a hell of a lot more to it than climbing a fence.

It's right in the title that this isn't a credible story.

>
> At least Irish isn't claiming it's a true story. In any event, this ain't
> the way I heard it. I do recall one of Aesop's Fables, "Androcles and
> the Lion", which is pretty similar.
>

Like everything else that emanates from Mike...complete and utter bullshit.
Bull elephant I suppose.

http://www.snopes.com/critters/malice/el...

W/Q

2/23/2014 6:03:00 PM

0

On Sunday, February 23, 2014 12:16:29 PM UTC-5, Dano wrote:
> "David Johnston" wrote in message news:lecaup$jfv$1@dont-email.me...
>
>
>
> On 2/20/2014 10:06 AM, Adam H. Kerman wrote:
>
> > Irish Mike <ad7cb8d@webnntp.invalid> wrote:
>
> >
>
> >> This is an Incredible story!
>
> >
>
> >> In 1986, Peter Davies was on holiday in Kenya after graduating from
>
> >> Northwestern University . On a hike through the bush, he came across a
>
> >> young bull elephant standing with one leg raised in the air.
>
> >
>
> >> The elephant seemed distressed, so Peter approached it very carefully.
>
> >> He got down on one knee, inspected the elephants foot, and found a large
>
> >> piece of wood deeply embedded in it.
>
> >
>
> >> As carefully and as gently as he could, Peter worked the wood out with
>
> >> his
>
> >> knife, after which the elephant gingerly put down its foot.
>
> >> The elephant turned to face the man, and with a rather curious look on
>
> >> its
>
> >> face, stared at him for several tense moments..
>
> >
>
> >> Peter stood frozen, thinking of nothing else but being trampled.
>
> >> Eventually the elephant trumpeted loudly, turned, and walked away.
>
> >> Peter never forgot that elephant or the events of that day.
>
> >
>
> >> Twenty years later, Peter was walking through the Chicago Zoo with his
>
> >> teen aged son. As they approached the elephant enclosure, one of the
>
> >> creatures turned and
>
> >> walked over to near where Peter and his son Cameron were standing.
>
> >
>
> >> The large bull elephant stared at Peter, lifted its front foot off the
>
> >> ground, then put it down. The elephant did that several times then
>
> >> trumpeted loudly, all the while staring at the man.
>
> >
>
> >> Remembering the encounter in 1986, Peter could not help wondering if this
>
> >> was the same elephant. Peter summoned up his courage, climbed over the
>
> >> railing, and made his way into the enclosure.
>
> >
>
> >> He walked right up to the elephant and stared back in wonder.
>
> >> The elephant trumpeted again, wrapped its trunk around one of Peter legs
>
> >> and slammed him against the railing, killing him instantly.
>
> >
>
> >> Probably wasn't the same elephant..
>
> >
>
> > You'd think I'd have heard of "Chicago Zoo" or read this story in 2006.
>
> > Odd. The zoos I'm familiar with built moats around elephant enclosures,
>
> > so there's a hell of a lot more to it than climbing a fence.
>
>
>
> It's right in the title that this isn't a credible story.
>
>
>
> >
>
> > At least Irish isn't claiming it's a true story. In any event, this ain't
>
> > the way I heard it. I do recall one of Aesop's Fables, "Androcles and
>
> > the Lion", which is pretty similar.
>
> >
>
>
>
> Like everything else that emanates from Mike...complete and utter bullshit.
>
> Bull elephant I suppose.
>
>
>
> http://www.snopes.com/critters/malice/el...


These right wingnuts. They always fall for stories like this and try to pass them off as fact. If only they did a little double-checking first before posting their nonsense, they wouldn't look so stupid. Hey. Where did Irish Mike go all of a sudden?