Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:03:12+00:00 2026-06-11T09:03:12+00:00

Update: part of the problem might have been solved by accessing the data like

  • 0

Update: part of the problem might have been solved by accessing the data like

first_name = graphdata[:first_name]

instead of like

first_name = userdata.first name

but when I go to save it, I’m now getting this error

 undefined method `save!' for #<Class:0x00000102dbe068>

Original problem

I’m sure there’s probably multiple problems with this code.

I’m playing around with a clone of a Rails app https://github.com/banane/sample-koala-rails-app that uses Koala to authenticate with Facebook and get user data. It does this with the callback method in the home_controller.rb below.

I’m trying to save the authentication token and the user data to a User model that I created.

In the callback method below, I inserted this code

     user = User.oath(session[:access_token], @user_info)   ### my code/ likely wrong
     session[:user_id] = user.id                            ### my code/ likely wrong

to try to save the data to the User model, using the ‘oath’ class method I made on the User model (see below). Note,I’m not even sure if I can pass that instance variable @user_info into the method…

When I test it, the error I get is

undefined method `name' for #<Hash:0x00000103457d70>

and the trace says

app/models/user.rb:8:in `oath'
  app/controllers/home_controller.rb:30:in `callback'

Here’s the code

User.rb

def self.oath(access_token, userdata)      #my code/ likely wrong


    name = userdata.name
    first_name = userdata.first_name
    last_name = userdata.last_name
    username = userdata.username
    gender = userdata.gender
    email = userdata.email
    access_token = access_token
    save!
  end

Home_controller.rb (towards the end of the callback method I try to save the user data)

def callback
    if params[:code]
        # acknowledge code and get access token from FB
          session[:access_token] = session[:oauth].get_access_token(params[:code])
        end     

         # auth established, now do a graph call:

        @api = Koala::Facebook::API.new(session[:access_token])
        begin
            @user_info = @api.get_object("me")
            @graph_data = @api.get_object("/me/statuses", "fields"=>"message")
        rescue Exception=>ex
            puts ex.message
        end

        user = User.oath(session[:access_token], @user_info)  #my code/likely wrong
        session[:user_id] = user.id


        respond_to do |format|
         format.html {   }           
        end


    end

The @user_info has all this data in it

{"id"=>"8331884858", "name"=>"Michael MYLASTNAME", "first_name"=>"Michael", "last_name"=>"MYLASTNAMe", "link"=>"http://www.facebook.com/myusername", "username"=>"myusername", "gender"=>"male", "email"=>"myemail", "timezone"=>5, "locale"=>"en_US", "verified"=>true, "updated_time"=>"2012-07-29T06:52:12+0000"}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:03:13+00:00Added an answer on June 11, 2026 at 9:03 am

    It sounds like you may be just accessing the hash incorrectly, try this:

      def self.oath(access_token, userdata)
        create! userdata.merge({:access_token => access_token})
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an update panel to have part of my page update asynchronously. Its
I would like to update (change the content) some part of the webpage without
I have a few files that were part of an update that were mistakenly
I'd like to use PowerShell as part of our automated build process to update
I have been struggling with this seeminly easy problem for 48 hours, and I
I tried to update some part of a matrix, I got the following error
For example, when I want to update a part of my page with AJAX
Is there a way to update only Hour part in a DateTime field?? If
I'm implementing a simple update mechanism for an application I'm writing the last part
I have this weird problem where my Google Maps API script doesn't work, no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.