当前位置:网站首页>STI, one controller
STI, one controller
2022-06-29 04:47:00 【Bustling city 】
problem :
I'm new to rails and I'm kind of stuck with this design problem, that might be easy to solve, but I don't get anywhere: I have two different kinds of advertisements: highlights and bargains. I'm a tough novice , It is difficult for me to solve this design problem , This may be easy to solve , But I have nowhere to go : I have two different advertisements : Highlights and bargains .Both of them have the same attributes: title, description and one image (with paperclip). They all have the same properties : title , Description and an image ( Using a paper clip ).They also have the same kind of actions to apply on them: index, new, edit, create, update and destroy. They also have the same action applied to them : Indexes , newly build , edit , establish , Update and destroy .
I set a STI like this: I set up one like this STI:
Ad Model: ad.rb Advertising model :ad.rb
class Ad < ActiveRecord::BaseendBargain Model: bargain.rb bargain model :bargain.rb
class Bargain < AdendHighlight Model: highlight.rb Highlight the model :highlight.rb
class Highlight < AdendThe problem is that I'd like to have only one controller ( AdsController ) that executes the actions I said on bargains or highlights depending on the URL, say www.foo.com/bargains[/...] or www.foo.com/highlights[/...]. The problem is that I think there is only one controller ( AdsController ) Do what I say on the bargain or highlight , Depending on URL, such as www.foo.com/bargains [/ ...] or www.foo. COM / Bright spot [/ ...].
For example: for example :
- GET www.foo.com/highlights => a list of all the ads that are highlights. obtain www.foo.com/highlights => A list of all the key advertisements .
- GET www.foo.com/highlights/new => form to create a new highlight etc... obtain www.foo.com/highlights/new => Tables to create new highlights ......
How can i do that? How can I do this ?
Thanks! thank you !
Solution :
Reference resources : https://stackoom.com/en/question/M0vH边栏推荐
- JDBC man Han building code
- Research Report on the overall scale, major manufacturers, major regions, product and application segmentation of spinning flow forming hub in the global market in 2022
- What are the circular statements of MySQL
- Mediator pattern
- MySQL subquery
- 如何用万用表测试电子部件
- The people's Bank of China printed and distributed the notice on supporting cross-border RMB settlement of new foreign trade formats
- Proxy mode (proxy)
- Network device setting / canceling console port login separate password
- Talking about Canary deployment
猜你喜欢

How to test electronic components with a multimeter

How to use the select statement of MySQL

Visitor pattern

Live broadcast appointment AWS data everywhere series activities

泰克DPO4104数字荧光示波器技术参数

Agilent digital multimeter software ns multimeter, real-time data acquisition and automatic data saving

ROS URDF model is parsed into KDL tree

Remediation for Unsafe Cryptographic Encryption

From zero to one, I will teach you to build a "search by text and map" search service (I)

【HackTheBox】dancing(SMB)
随机推荐
C language uses printf to print love, Mars strikes the earth, etc., which are constantly updated
Apifox: it is not only an API debugging tool, but also a collaboration artifact of the development team
data management plan
Has my future been considered in the cloud native development route?
IDENTITY
An efficient flutter hybrid stack management scheme with zero intrusion, you deserve it!
Talking about Canary deployment
5000+ word interpretation | Product Manager: how to do a good job in component selection?
仿真與燒錄程序有哪幾種方式?(包含常用工具與使用方式)
Flyweight pattern
如何创建 robots.txt 文件?
How to create a subtype like relationship between two generic classes when the classes are generic related
Introduction to Bert and Vit
[Verilog quick start of Niuke network question brushing series] ~ asynchronous reset Series T trigger
real time AI based system questionaires
【代码随想录-动态规划】最长公共子序列
Lua protobuff Emmy Lua wheel
Research Report on the overall scale, major manufacturers, major regions, product and application segmentation of disposable hearing aid batteries in the global market in 2022
What are the MySQL database constraint types
汉泰示波器软件|汉泰示波器上位机软件NS-Scope,任意添加测量数据