-
Notifications
You must be signed in to change notification settings - Fork 333
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
template source is evaluated as empty #35
Comments
Can you experiment a bit, try a simple case and just do # app/views/attendees/show.json.rabl
attributes :oid, :first_name, :last_name and then make sure # app/controllers/attendees_controller.rb
respond_to :json
def show
@attendee = Attendee.first
respond_with(@attendee)
end and see if it is still blank? |
I did that and I still end up with the same result. The only difference now is that def show
@attendee = Attendee.first
respond_with {puts @attendee.inspect; @attendee}
end The puts @attendee.inspect results in: <Attendee _id: 4de6fb174820686dfc000001, _type: "Attendee", _id: BSON::ObjectId('4de6fb174820686dfc000001'), created_at: 2011-06-02 02:53:11 UTC, updated_at: 2011-06-02 02:53:11 UTC, email: "jimmy@aol.com", encrypted_password: "5d6bc901e1190e3f4c949b3683bbea0d913ced184c637884ff53e3085d0b708260a72f4e1c56537a380f21f03928cee42c20d49ca2f193f4dbeadff578a58c8b", authentication_token: nil, remember_created_at: nil, password_salt: "kw5kyj77gM8VXprBYAzk", reset_password_token: nil, failed_attempts: 0, unlock_token: nil, locked_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, first_name: "Jimmy", last_name: "Dean", oid: "aEcDxHqEnc", event_oids: ["shQdQBIK21"]> |
Which ORM are you using? I think I am beginning to see the possible problem... Sorry should have asked that first, I have only tested RABL with Mongoid, Datamapper, ActiveRecord and MongoMapper. Does the attendee object respond to the |
I am using mongoid 2.0.1 with rails 3.0.7. The @Attendee instance is a Mongoid instance and it does respond to valid? with true. |
Fascinating, I have several apps (Rails 3 / Mongoid 2.0.1) using RABL right now, I have a hard time understanding why even the simplest case fails for you. Unfortunately don't have time to debug this right now :( Try this out of interest: app/views/attendees/show.json.rabl
node :foo do |a|
"bar"
end and see if that shows up with a |
I modified show.json.rabl as recommended, and still nothing. Where I identify the problem is in RABL_ROOT/lib/rabl/template.rb line 56. The variable |
This is my backtrace
|
I understand thanks for explaining, can you try this guy's fork: https://github.com/skyeagle/rabl He fixed Rails 3 support and support for Rails 3.1. Perhaps this can also fix the template source issue you are experiencing. |
I tried out the fork from skyeagle and I'm still having the same issue. |
I came up with a fix on a fork and requested a pull (#36). nesquena, thank you for your help on this. |
@mrinterweb it seems like you were using rspec to test a controller without |
@agibralter Thanks for the tip on render_views. That was throwing me off. |
I set a debug point on line 55 of lib/rabl/template.rb. When I
template.inspect
I get "app/views/attendee/show.rabl" which is correct, buttemplate.source
returns and empty string.If I then do
File.open(Rails.root + template.inspect, 'r') { |f| puts f.read }
that produces:app/views/attendee/base.rabl
I am setting @Attendee in my show action and I can not figure out why the rendered result is:
The text was updated successfully, but these errors were encountered: