Comments (7)
It seems the failure is in the extends 'shared/success'
I'm not sure what is causing it though but here's the code in that partial and I'm not sure why it would cause that.
object false
node(:status) { :success }
node(:message) { @message }
from rabl-rails.
The ActionView
error output is pretty much useless here. Can you reproduce this issue in a small app?
from rabl-rails.
This actually rings a bell - It's exactly what happened to me in #15.
Sorry, I just couldn't reproduce the exact error.
from rabl-rails.
@fnordfish @ccocchi I actually managed to reproduce the same error in a completely different app. Without even running tests. Here's what happened. I made two routes.
GET /users = > "users#index"
Here's the code for index:
def index
@users = User.all
@message = "Testing index"
render 'users/index'
end
Here's the code for the views:
index.json.rabl
object false
node(:users) { partial('users/_show', object: @users)}
extends 'shared/success'
_show.json.rabl
attributes :id, :first_name, :last_name, :email
shared/success.json.rabl
object false
node(:status) { :success }
node(:message) { @message }
This action actually displays everything correctly with the JSON when called from the browser the output is like such:
{"users":[{"id":18,"first_name":"leo","last_name":"correa","email":"[email protected]"}],"status":"success","message":"Testing index"}
Where I can reproduce the issue is here, I have another route called GET /private/user => "users#show"
show action
def show
@user = User.find(18)
@message = "Hello there"
render 'users/show'
end
show.json.rabl
object false
node(:user) { partial('users/show', object: @user) }
extends 'shared/success'
Error I get is the same:
TypeError in Users#show
Showing /Users/leo/some_app/app/views/users/show.json.rabl where line #2 raised:
can't convert nil into String
Extracted source (around line #2):
1: object false
2:
3: node(:user) { partial('users/show', object: @user) }
4:
5: extends 'shared/success'
Rails.root: /Users/leo/work/cloud/cloudid
Application Trace | Framework Trace | Full Trace
app/views/users/show.json.rabl:2:in `_app_views_users_show_json_rabl__4099721713394439804_70329454872940'
app/controllers/users_controller.rb:43:in `show'
This is without testing on Rspec or initially having rabl
. Pretty much is a new app with rabl-rails
from the beginning and checking the results on the browser.
from rabl-rails.
Scratch that, It seems that what was causing the error was this
node(:user) { partial('users/show', object: @user) }
Once I switched it to
node(:user) { partial('users/_show', object: @user) }
it worked. I'm going to write some rspec tests for it and see if I can replicate the issue
from rabl-rails.
So I was not able to reproduce the issue with the small app. I'll go back to big app and try to debug and see what the issue was.
from rabl-rails.
I've got the same: #15 (comment)
from rabl-rails.
Related Issues (20)
- rabl-rails renders JSON instead of XML in some cases HOT 3
- iso8601 dates break on 0.4.0 HOT 1
- New way of format retrieving caused problems with gon gem HOT 4
- wiki page 'Render object directly' references to non existing class HOT 1
- Rails 4.2 HOT 4
- Object 'nil' with extends HOT 1
- fields filter?
- Conditional attributes not working HOT 1
- use_custom_responder = true doesn't work on RoR 4.2 HOT 1
- Not being able to use a cache key in rabl generated by controller. HOT 2
- Object root not included in 0.4.2, but was in 0.4.1 HOT 7
- Response contains ":" in rails 5 HOT 1
- rabl-rails for rails-5-api? HOT 5
- undefined method for nil:NilClass on Rails 5.0.1 HOT 2
- Upgrading to 0.5.0 from 0.4.3 encountering error "undefined method `render' for RablRails:Module" HOT 6
- Results caching with object set to false
- Need to remove .json from url
- `rendered_format` is removed in Rails 6.1 HOT 4
- single arity deprecation warning for Rails 6.1 HOT 2
- Rails 6 warning: autoloading ActionController::Base during initialization HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rabl-rails.