Skip to content
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

Demo on website doesn't say what to import #4

Open
Xe opened this issue Mar 27, 2018 · 3 comments
Open

Demo on website doesn't say what to import #4

Xe opened this issue Mar 27, 2018 · 3 comments

Comments

@Xe
Copy link

Xe commented Mar 27, 2018

class SerializablePost < JSONAPI::Serializable::Resource
  type 'posts'

  attributes :title, :body

  attribute :date do
    @object.created_at
  end

  belongs_to :author

  has_many :comments do
    data do
      @object.published_comments
    end

    link :related do
      @url_helpers.user_posts_url(@object.id)
    end

    meta do
      { count: @object.published_comments.count }
    end
  end

  link :self do
    @url_helpers.post_url(@object.id)
  end

  meta do
    { featured: true }
  end
end

What do I pass to require to get that class loaded into ruby? I can't figure it out.

@Dan2552
Copy link

Dan2552 commented May 21, 2018

Probably a bit late, but you can require 'jsonapi/serializable'

@Xe
Copy link
Author

Xe commented May 23, 2018

Why isn't this documented on the website?

@beauby
Copy link
Member

beauby commented Jun 13, 2018

@Xe Short answer is: this is an open source project, I built/maintain it on my free time, feel free to make a PR to https://github.com/jsonapi-rb/jsonapi-rb.github.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants