Attribute is not accessible in Class (Sinatra, Twitter)

181 views
Skip to first unread message

Malachai Frazier

unread,
Aug 11, 2012, 10:37:02 PM8/11/12
to sing...@googlegroups.com
Weirdness with my POST action. I'm trying to create a new user with a successful Twitter connection. But ['data']['screen_name'] isn't letting me access the screen_name directly. Is there a known 'best practice' workaround for this?:

post "/success" do
selfy = HTTParty.get(self_url,{
:query => {:access_token => session[:access_token], :map => true}}).first
User.create selfy['data']['screen_name'] => params[:username], :email => params[:email]
@username = params[:username]
redirect "/:username"


ArgumentError at /success

The attribute 'captcussa' is not accessible in User

Kristján Pétursson

unread,
Aug 13, 2012, 2:55:52 PM8/13/12
to sing...@googlegroups.com
It looks to me like what's actually happening there is you're trying to use the screen_name as a column in your User table.  If you schema is something like

User(user_name:String, screen_name:String, email:String)

Then your create command should be

User.create(:user_name => params[:username], :screen_name => selfy['data']['screen_name'], :email => params[:email])

Your current code is trying to do

User.create('captcussa' => params[:username], :email => params[:email])

But there's no 'captcussa' column in your schema, so the ORM hasn't put an accessor on the User object

--
You received this message because you are subscribed to the Google Groups "Singly API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/singlyapi/-/0ZR3Psq58GoJ.
To post to this group, send email to sing...@googlegroups.com.
To unsubscribe from this group, send email to singlyapi+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/singlyapi?hl=en.

Reply all
Reply to author
Forward
0 new messages