GithubHelp home page GithubHelp logo

jsonify-rails's Issues

Stripping out whitespace in strings

I'm having some problems using strings in jsonify. I've been using jsonify fine for a year with no problems. Now I've across one particular method that seems to strip out all the whitespace in strings.

For example this:

json.test 'hello world'

Produces:

{
"test": "helloworld"
}

I eventually narrowed the problem down to sending the json with a HTTP status code of 403. If I send with a 200 status code it works fine.

Rendering a partial within a loop

Hi,
I'm trying to render a partial multiple times (for the index action) and it's only returning the last item:

Partial _child.json.jsonify

json.name child.name

File index.json.jsonify

@children.each do |child|
  json.ingest!(render partial: child)
end

Actual result:

{"name":"Pedrito"}

Expected result:

[{"name":"Horacio"},{"name":"Pepito"},{"name":"Pedrito"}]

I also tried:

@children.each do |child|
  json << json.ingest!(render partial: child)
end

But the result was:

{"name":"Pedrito","#<Jsonify::JsonObject:0x00000002333ef0>":null,"[#<Jsonify::JsonPair:0x00000002320df0 @key=\"name\", @value=\"Pepito\">]":null,"[#<Jsonify::JsonPair:0x00000002306658 @key=\"name\", @value=\"Pedrito\">]":null}

Render jsonify templates within controller context

similar to haml, my templates have access to certain controller/helper methods instead of solely accessing instance variables.

a great example of this is when integrating with Devise authentication and accessing the current_user method from within my templates.

how difficult is it to expose these same methods within jsonify templates?

No pretty printing?

Hi - I've followed your instructions about getting pretty printing in a Rails 3.1 app working to no avail. I'm including my application.rb here:

require File.expand_path('../boot', __FILE__)

require 'rails/all'

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
  # Bundler.require(:default, :assets, Rails.env)
end

module MyApp
  class Application < Rails::Application
    # Configure the default encoding used in templates for Ruby 1.9.
    config.encoding = "utf-8"

    # Configure sensitive parameters which will be filtered from the log file.
    config.filter_parameters += [:password]

    # Pretty-print JSON output
    config.jsonify_format = :pretty

    # Enable the asset pipeline
    config.assets.enabled = true

    # Version of your assets, change this if you want to expire all your assets
    config.assets.version = '1.0'
  end
end

The output all runs on a single line. Am I missing something obvious, like a 'require' statement?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.