Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created September 25, 2011 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchrisadams/1241116 to your computer and use it in GitHub Desktop.
Save mrchrisadams/1241116 to your computer and use it in GitHub Desktop.
attributes_not_being_assigned
class Checkin < ActiveRecord::Base
belongs_to :user
# switching off validation to see if the reason attributes aren't being assigned is due to them
# validates :lat, :lon, :foursquare_id, :timestamp, :venue_name, :presence => true
attr_accessor :lat, :lon, :foursquare_id, :timestamp, :venue_name
end
Loading development environment (Rails 3.0.10)
pry(main)> check = Checkin.find_or_initialize_by_foursquare_id('4e7e11b3d3e31f4bb86b9cf2')
=> #<Checkin id: nil, lat: nil, lon: nil, timestamp: nil, foursquare_id: nil, timezone: nil, created_at: nil, updated_at: nil, venue_name: nil, user_id: nil>
pry(main)> check.foursquare_id = '4e7e11b3d3e31f4bb86b9cf2'
=> "4e7e11b3d3e31f4bb86b9cf2"
pry(main)> check
=> #<Checkin id: nil, lat: nil, lon: nil, timestamp: nil, foursquare_id: nil, timezone: nil, created_at: nil, updated_at: nil, venue_name: nil, user_id: nil>
ActiveRecord::Schema.define(:version => 20110925195511) do
create_table "checkins", :force => true do |t|
t.string "lat"
t.string "lon"
t.datetime "timestamp"
t.string "foursquare_id"
t.string "timezone"
t.datetime "created_at"
t.datetime "updated_at"
t.string "venue_name"
t.integer "user_id"
end
create_table "users", :force => true do |t|
t.string "email"
t.string "token"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "foursquare_id"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment