-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
RABL with a basic ruby class #275
Comments
Are you referring to the latter part that I just added? Here's a variation of a template from the integration suite: object @post
cache @post
attributes :title, :body
attributes :created_at => :posted_at
node(:foo_helper) { helper_foo }
node(:post_object) do |post|
[post.title, post.body]
end
child :user do
attributes :username, :email, :location
end
glue :user do
attributes :username => :author_name
end
code(:created_date) do |p|
partial("posts/date", :object => p.created_at)
end {"article"=>
{"title"=>"Foo",
"body"=>"Bar",
"posted_at"=>"2012-06-27T16:22:24Z",
"foo_helper"=>"FOO!",
"post_object"=>["Foo", "Bar"],
"user"=>{"username"=>"billybob", "email"=>"billy@bob.com", "location"=>"SF"},
"author_name"=>"billybob",
"created_date"=>{"day"=>27, "hour"=>16, "full"=>"2012-06-27T16:22:24Z"}}} |
I'm referring to the part where you create a basic ruby class class MyClass Then you try and do object false in the rabl template. It tries to call to_a and fails with undefined_method |
Here's a gist of what it would ideally be... https://gist.github.com/3005300 I tried changing it around to use object false, but that doesn't seem to work |
In your case, you have a valid object (@machines) and so it should work. I'll be back in an hour from lunch and I'll try it out. |
Nevermind it was a me issue. I wasn't requesting json... l-P Looks like it's time for me to take a lunch break too! |
Awesome - I was going to say next is to verify that the template is being accessed and throwing a debugger call into the rabl file itself. Glad it's working! |
Unless I'm doing something wrong, this Tips & Tricks no longer seems to work.
https://github.com/nesquena/rabl/wiki/Tips-and-tricks
The text was updated successfully, but these errors were encountered: