Save a params value on database

Hello,
I think i have a stupid problem but…it’s a problem

i’ve a session param like session[:idLayer]

when i try to save this value on my database, i always have “1” value
recorded.

my controller is :

blocElem = BlocElement.new
blocElem.bloc_id = session[:idBloc]
blocElem.page_id = session[:idLayer]
blocElem.element_id = elem.id
blocElem.position = newPosition
blocElem.save

my session param value is “2” and the record save is “1”.

i’ve trying to replace my session param by a static value and it’s ok :
blocElem = BlocElement.new
blocElem.bloc_id = session[:idBloc]
blocElem.page_id = 2
blocElem.element_id = elem.id
blocElem.position = newPosition
blocElem.save

i don’t understand what is the problem.
help !!