-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom-Resource Classes: undefined method `[]=' for nil:NilClass in resource_builder:182 #79
Comments
Hey @toadle, Your Please let me know if that fixes your problem |
@dlitvakb Thanks for getting back! Of course, that works. That is what I've been doing all along. Therefore I was hoping the But I suppose that is not possible, right? |
@toadle Yes, as you say that works, the thing is that for parsing the api_response['fields'],
Hope that helps |
@dlitvakb But still, when doing
and having
Gives me
Sorry, if I'm not getting this. |
You probably wanted to tag @dlitvakb 👯 |
@danihodovic Whoops, sorry. |
Hey @toadle Don't mess with @danihodovic he is training boxing! 👊 I'll look into it in more detail and try to reproduce it, Can you paste me the JSON Preview for the Content Type you are using? |
JSON-Preview:
|
@toadle sorry for the delay on the response, I was sick on Friday. I'll keep looking onto this, thanks for providing the JSON |
Hey @toadle, I found a solution, You can currently use this workaround while I add it into the core library The following code is a very simple local test I used for making your code work. #!/usr/bin/env ruby
require 'contentful'
class Kategorie < Contentful::Entry
property :title
property :slug
property :image
property :top
property :subcategories
property :featured_articles
property :cat_intro_head
property :cat_introduction
property :seo_text
property :meta_keywords
property :meta_description
property :meta_robots
def initialize(*)
super
client.content_type(content_type['sys']['id']).fields.each do |f|
define_singleton_method Contentful::Support.snakify(f.id).to_sym do |wanted_locale = default_locale|
fields(wanted_locale)[f.id.to_sym]
end
end
end
end
def assert(expectee, expected)
raise unless expected == expectee
end
def main
client = Contentful::Client.new(
access_token: 'd230af21290965e573830bcddadbac0cd7dc13b926fda7394981d610c7f61ee0',
space: 'g2b4ltw00meh',
dynamic_entries: :auto,
entry_mapping: {
'kategorie' => Kategorie
}
)
entry = client.entries.first
assert(entry.is_a?(Kategorie), true)
assert(entry.title, "Some Title")
assert(entry.slug, "/asda.html")
assert(entry.featuredArticles.first.is_a?(Contentful::Link), true)
assert(entry.top, true)
end
main Currently it relies on defining the properties from the fields values, as DynamicEntry only defines that upon creation and it's static. Solution will move the code I'm using for the workaround (which is a slightly modified version of the one in the Please let me know if this helps cc @grncdr |
Hey guys,
thanks for releasing 0.7 and fixing my last issue #69 . Today I set off to give this a shot, but still am not able to figure this out correctly. Perhaps I'm still doing something wrong:
I have a custom-resource
Contentful::Category
like this:where
Contentful::BaseEntry
looks like this:All properties of
Contentful::Category
map to the attributes we have for our Content-Type.I pass
Contentful::Category
to theContentful::Client
in theresource_mapping
, when it's content-type's ID appears.Now when calling
client.entries('content_type' => <category content-type-id>)
it gives me:Which I can't really figure out why. Am I doing this right?
The text was updated successfully, but these errors were encountered: