Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8959565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:28:19+00:00 2026-06-15T15:28:19+00:00

In my Rails application I have created a controller to get data from database

  • 0

In my Rails application I have created a controller to get data from database which also includes params in model as follows.

The problem is that there are no html pages in views folder.. Do I need to run the controller??? I want the output i json format.. How are the html pages created and where can i see my json format of data…

# shoppingDemo.rb (controller)
class ShoppingDemo < ApplicationController
  def index
    @lists=products.all;
    respond_to do |format|
      format.html
      format.json { render json: @lists}
    end
  end

  def show
    @products = products.find(params[:prod_id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @products }
    end
  end
end

# products(model)
class products < Activerecord::Base
  attr_accessible :model_name, :brand_name, :price, :discount, :qty_available
end

What is the next step to create html pages or to see my data from database in json format.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:28:20+00:00Added an answer on June 15, 2026 at 3:28 pm

    You should fix some issues:

    1) in Model

    class Product

    2) in Controller

    @lists = Product.all

    @products = Product.find(params[:id])

    3) You should create routes in config/routes.rb

    resources :products
    

    It will create routes for index, show, new, create, update, destroy actions. Read more here.

    After that you can access your products list through http request on http://localhost:3000/products and show your product with id=1 on http://localhost:3000/products/1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a blog application using Ruby on Rails which includes the ability
Have been trying to get a fresh, just created rails application to work on
I have created a table in my Ruby on Rails application that I am
I have created a simple blog application with Ruby on Rails. The applications consists
I have a Rails 3.2.2 application using Ruby version 1.9.2. I have created basic
In my rails application I have upgraded in the past from rails 3.0 to
I have recently created a new rails 3 application, using the code that I
I have a prescription model in my Rails 3 application. I am trying to
I have a simple rails application in which I'm trying to add a very
Is is possible to create a recursive route in Rails? I have an application,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.