Forum: Ruby on Rails rails with mongodb

45d36215e177b195718d07907a992721?d=identicon&s=25 Vignesh Gopalakrishnan (viki_viki)
on 2014-03-09 07:26
Hello viewers .. I'm Doing a project on rails with mongoDB as a backend
database. When we learn a new programming language we start with writing
a helloworld program . In the same way if we want to work with a web
application we usually do a simple database connection .. We just create
a page with a single text box and a simple button . When we click the
button the data should be fetched from a database and showed in the
textbox . or otherwise when clicked the data in textbox should be sent
to the backend db . this is what we do . And i went through the same .
Used this tutorial
"http://moredevideas.com/getting-started-rails-4-wi...  Its
really superb . And i really executed it well and got it working . As
per the tutorial i executed the command

"rails generate scaffold product name description price:float"  ..

It generated some of the files in the app/view folder and one the file
named "index.json.jbuilder" . And the file contains this code


"json.array!(@products) do |product|
  json.extract! product, :id, :name, :description, :price
  json.url product_url(product, format: :json)
end" ..

What does this code actually mean.i'm not able to understand it.. Any
suggestions would be helpful .
F50d3b02eee623a2172b58c09fe31c2c?d=identicon&s=25 mike (Guest)
on 2014-03-09 17:14
(Received via mailing list)
On Sunday, March 9, 2014 1:26:02 AM UTC-5, Ruby-Forum.com User wrote:
> "http://moredevideas.com/getting-started-rails-4-wi...  Its
>   json.extract! product, :id, :name, :description, :price
>   json.url product_url(product, format: :json)
> end" ..
>
> What does this code actually mean.i'm not able to understand it.. Any
> suggestions would be helpful .
>
> --
> Posted via http://www.ruby-forum.com/.
>

The code is syntax for the DSL for the jbuilder gem.  You can view the
documentation at:

https://github.com/rails/jbuilder
45d36215e177b195718d07907a992721?d=identicon&s=25 Vignesh Gopalakrishnan (viki_viki)
on 2014-03-10 12:37
> The code is syntax for the DSL for the jbuilder gem.  You can view the
> documentation at:
>
> https://github.com/rails/jbuilder


Thank you Mike ..
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.