Rails drive me crazy. I'm trying to respond to with an action with JSON. My goal is to let be the JSON the only format for a response to a URL.
Let's see some code.
The Model is a Devise user, with some added field.
The Controller is my UsersController
that has this action
# /app/controllers/users_controller.rb
def static
render json: current_user
end
I got also this jbuilder view
# /app/views/users/static.json.jbuilder
json.content format_content(@user.content)
json.author do
json.name @user.name
json.email_address @user.email
end
if current_user.admin?
json.someValue "foo"
end
this View doesn't do some interesting stuff, but It's just a try.
Anyway I'll never get the static.json.jbuilder
content. I always get all Devise user's content as a JSON.
Am I doing something wrong? (or better: where I done the epic fail?)