Open Etsija opened 7 years ago
I made a very simple test table, which has only three columns: Name column (integer), one text and one float number column.
@record = Airtable::Record.new() @tblTest.create(@record)
creates an empty row.
p @record => <Airtable::Record :id=>"recMZUN8G5AklDSP5">
@record[:laji] = "test text" p @record => <Airtable::Record :id=>"recMZUN8G5AklDSP5", :laji=>"test text">
@tblTest.update(@record) does nothing at all. Nor does the record get created when I provide the Airtable::Record.new() some initial values. Only the empty record creation works.
If I'm trying to do this incorrectly, please forgive me: I am new to Ruby. At least you should consider updating README.md and give some more precise examples on record creation, update etc.
You may want to check capitalization of the keys to column names. I had that issue as well, and since the gem doesn't raise an error for an API call failure you won't get any ruby errors.
@record = Airtable::Record.new(:name => "Sarah Jaine", :email => "sarah@jaine.com")
should be
@record = Airtable::Record.new(:Name => "Sarah Jaine", :email => "sarah@jaine.com")
with the default Name
column.
I've been meaning to do some work to raise some errors in the gem, which should help developers understand why a request is not behaving as expected.
Yes, after some trials I found out that this works:
@record = Airtable::Record.new(Name: "Sarah Jaine")
As I said, I'm new to Ruby, but is that actually the same as
@record = Airtable::Record.new(:Name => "Sarah Jaine")
or is there an important difference?
I didn't find out before that capitalization is important, because when I print out the records with "p" (for example), the attributes are not capitalized in the output, even if my table columns are! Ruby can be a bit confusing in the beginning...
@Etsija in most cases it's stylistic, but the "hashrocket" style (:key => 'value'
) is a bit more flexible in terms of the type of key's you can use.
here's a nice short blog post I just found with a little more info - http://alwayscoding.ca/momentos/2012/06/15/ruby-hash-syntax-hashrocket-vs-json-style/
Well this is weird: my "name" column is "Nro". In record creation, the column needs to be case sensitive. But when I write this:
def find_id (records, nro) records.each do |record| if record[:nro] == nro return record.id end end end
it only works with ":nro" but not with ":Nro". How is that?
(And, obviously I don't know how to cut the code in lines...)
There's some magic from HashWithIndifferentAccess or from converting field names to symbols. I have a branch that tries to get rid of ActiveSupport dependency. That will likely get rid of this implicit behavior and allow using symbols for field access only when they match the column name exactly. That might be somewhat rare and unreliable, so it's possible we'll remove symbol-based access altogether.
Alex
On Friday, October 21, 2016, Jyrki Keisala notifications@github.com wrote:
Well this is weird: my "name" column is "Nro". In record creation, the column needs to be case sensitive. But when I write this: def find_id (records, nro) records.each do |record| if record[:nro] == nro return record.id end end end it only works with ":nro" but not with ":Nro". How is that?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Airtable/airtable-ruby/issues/14#issuecomment-255508353, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQEoLixy5ayd_AT1XeshDYuVIogwI7-ks5q2ZxNgaJpZM4Kco7f .
Sent from Gmail Mobile on my iPhone
I had a similar issue where the default Name column expected the key to be capitalized as :Name (or you could change the column name).
The client just returns false for the failed API call, rather than raising an error, which is something I've been meaning to work on a PR for.
On Thursday, October 20, 2016, Jyrki Keisala notifications@github.com wrote:
I am currently able to create an empty record (which is seen in Airtable by a new empty row) with @record https://github.com/record = Airtable::Record.new() @table.create(@record https://github.com/record)
but whenever I try to create a record with some predefined keys as in your example
@record https://github.com/record = Airtable::Record.new(:name => "Sarah Jaine", :email => "sarah@jaine.com javascript:_e(%7B%7D,'cvml','sarah@jaine.com');") @table.create(@record https://github.com/record)
nothing at all gets created. Documentation is very minimalistic, so: does the record need to include all the keys? Any idea why my record creation with any real values fails?
I get no Ruby errors, but nothing gets created.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Airtable/airtable-ruby/issues/14, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4VmU2ejvg58yLXS5rYBJwITwX7T85Sks5q1-D_gaJpZM4Kco7f .
vcardme.com/sam
Just ran into the same issue (record not being created, method returning false
and no error). I think it's worth mentioning, that the version in this repo's master
branch actually does raise an exception with the correct error message. However, the official gem isn't up to date with this repo (installs 0.0.9
vs 1.1.1
in master
), so I worked around that by using the gem from GitHub, like this:
gem 'airtable', github: 'Airtable/airtable-ruby'
Hope this saves someone else some time, if they also run into it.
I am currently able to create an empty record (which is seen in Airtable by a new empty row) with @record = Airtable::Record.new() @table.create(@record)
but whenever I try to create a record with some predefined keys as in your example
@record = Airtable::Record.new(:name => "Sarah Jaine", :email => "sarah@jaine.com") @table.create(@record)
(Of course I am using my own column names...)
nothing at all gets created. Documentation is very minimalistic, so: does the record need to include all the keys? Any idea why my record creation with any real values fails?
I get no Ruby errors, but nothing gets created.