Answer the question
In order to leave comments, you need to log in
How to write a request in rails?
There is a standard model product (id, name), address 127.0.0.1/products
AND a model product_property (id, value, product_id), a one-to-many relationship
models/product.rb
class Product < ActiveRecord::Base
has_many :product_properties
end
class Product_property < ActiveRecord::Base
belongs_to :product
end
Appname::Application.routes.draw do
resources :products do
resources :product_properties
end
Answer the question
In order to leave comments, you need to log in
Judging by the routes, your request will fall into the index ProductProperty action of the controller, the product identifier will be available there as params[: product_id], but then everything is simple
In the view, display @properties
And read all such tutorials)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question