Topic: How do you get a session value that's a string into an integer?

I tested my form to see that I've got my user.id in a cookie as shown in this cookied.inspect:
Back {"_openidauth_session_id"=>["0705e678bbdccae35898bf038e6a7082"], "password_hash"=>["f09a8fc9dec7fd16280d95dc3dba2c83cda520f2"], "user_id"=>["1"]}
I then attempt to convert this value into an integer (as shown)
@topic.user_id  = @cookies[:user_id].to_i
and when I save the record, I get the validation error that user_id is blank?
I've tried all kinds of way to get this integer into the topic.user_id field such as:
params[:user_id]  = @cookies[:user_id].to_i
and the validate keeps on firing.
Could you suggest any other ways to accomplish this?
Thank you,
Kathy

Re: How do you get a session value that's a string into an integer?

Could you post the code your using? One thing you could try, if you're doing:

@topic = Topic.new(params[:topic])

Before that put:
params[:topic][:user_id] = cookies[:user_id].to_i

Alex

P.S. It shouldn't matter, but its better to use cookies rather than @cookies wink

Re: How do you get a session value that's a string into an integer?

Alex,
I don't know if you've ever built a forum for your users' but I'm sure learning a lot. I couldn't figure out why the current_user was giving the "User value not entered?" although my actual field in the record was 'user_id'. I finally figured out that because the topic 'belongs_to' the user record that the CREATE action has to look something like this;
  def create
    @topic = @forum.topics.build(params[:topic])
    @topic.user = current_user
    respond_to do |format|
      if @topic.save
Anyway, it would give me a thrill if someday I could help you.
Thanks,
Kathleen