While working on tutorial 17 of the great rapid Rails 3 with Hobo I
was geting an error when the params[:sort] was not defined in the
following command:
@reqlist = @project.requirements.where(["title
like ?","%#{params[:search]}
%"]).order(parse_sort_param(:title,:status).join(' '))
So I desided to validate for the prescence of params[:sort].
Then I decided to go a step furter and do the join in the same method.
It will be needed anyway, so I sugest to leave it in this way:
def parse_sort_param(*sort_fields)
if params[:sort]
_, desc, field = *params[:sort]._?.match(/^(-)?([a-z_]+(?:\.[a-
z_]+)?)$/)
if field
if field.in?(sort_fields.*.to_s)
@sort_field = field
@sort_direction = desc ? "desc" : "asc"
[@sort_field, @sort_direction].join(' ')
end
end
else
''
end
end
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en.