I have a link where I need to pass a sequence of params, where 2 params are always nill.
link_to go_to_action_path(id, par_01, par_02, par_03, par_04)
In some cases are the par_01
and par_02
nil
, in other par_03
and par_04
.
If I have these values in the variables:
par_01 = nil
par_02 = nil
par_03 = 'a'
par_04 = 'b'
And then in the go_to_action
action:
p01 = params[:par_01]
p02 = params[:par_02]
p03 = params[:par_03]
p04 = params[:par_04]
I get these values:
p01 => a
p02 => b
p03 =>
p04 =>
In other words, the variables par_01
and par_02
will be thrown away and on their places will be moved in par_03
and par_04
.
How can I force the link_to
to accept a param with a nil
value? I was thinking about placing there 0
s instead of nil
s and then manually parse it in the controller action, but this is quite an ugly solution.