AnApprentice
AnApprentice

Reputation: 110960

Ruby, Getting a list count from a Param?

in my Rails 3 app, I have a form that posts XXX,XXXXXXXX What I want to be able to do is something like so:

params[:myfield].count
or 
params[:myfield].size

But that always returns 1, how can I get a count for the number of items by comma separation?

Thanks

Upvotes: 0

Views: 1031

Answers (1)

Reuben Mallaby
Reuben Mallaby

Reputation: 5763

params[:myfield].split(",").size

Upvotes: 3

Related Questions