Outputting JSON on webpage

30 views
Skip to first unread message

Mohammed Rashid

unread,
May 12, 2015, 9:28:29 AM5/12/15
to rubyonra...@googlegroups.com
I have been given a task to output json on web page using Ruby and/or
Rails. I would like to use both. I have to consume json from endpoint
and have been given a URL link to it. It should be served up on a web
server. I think I have an understanding of how to do it. I will use
rails api gem.

Can someone please tell me if this is the right way? any recommendation
as or advice as is the first time I am using JSON and RoR together.


I also have to use testing I will use BDD or TDD using capybara and
rspec.

--
Posted via http://www.ruby-forum.com/.

Vladimir Gordeev

unread,
May 12, 2015, 9:41:15 AM5/12/15
to rubyonra...@googlegroups.com
What task is precisely? You need just to proxy json data from other service?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e1da43d7583992ead4a3bb9bd2057e5f%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Mohammed Rashid

unread,
May 12, 2015, 10:04:17 AM5/12/15
to rubyonra...@googlegroups.com
Yes that is exactly what I need to do. I have been given a link which
has json data. It must be outputted to ruby web page.

Vladimir Gordeev

unread,
May 12, 2015, 10:40:21 AM5/12/15
to rubyonra...@googlegroups.com
Well, you can do simply this:

require 'open-uri'

class MyController
  def show
    content = open(URL_TO_FETCH_FROM).read
    render text: content
  end
end

Primitive solution

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages