[英]How do I model my Rails application where users search for events and save the ones that interest them?
I am using three models: - users - events - user_events (the join table) 我正在使用三种模型:-用户-事件-user_events(联接表)
I feel like I do not need to save every search result because it would be unnecessary. 我觉得我不需要保存每个搜索结果,因为这是不必要的。 The search will query two APIs and display maybe the top 10 results and display them to the user. 搜索将查询两个API,并可能显示前10个结果并将其显示给用户。 The user then might be interested in one or two of these events and add them to a list of things that interest them, a bookmark, if you may. 然后,用户可能会对这些事件中的一个或两个感兴趣,并将它们添加到感兴趣的事物列表中,如果需要的话,可以添加为书签。 Bookmarks that are happening on the same day should then be grouped together for the users organizational purposes. 然后,出于用户组织目的,应将同一天发生的书签归为一组。
Should I make another search model along with a search controller? 我应该与搜索控制器一起创建另一个搜索模型吗? I'm fairly new to Rails and need some advice on this topic. 我刚接触Rails,需要有关此主题的一些建议。
I would advise you make a bookmark or search class to store a search when a user wants to save it. 我建议您在用户要保存书签时,使它成为书签或搜索类别以存储搜索。 Then you can construct a has_many relationship between a user and a bookmark. 然后,您可以在用户和书签之间构造has_many关系。 So a user will have many bookmarks. 因此,用户将拥有许多书签。 See this for more documentation: http://guides.rubyonrails.org/association_basics.html#the-has-many-association 请参阅此以获取更多文档: http : //guides.rubyonrails.org/association_basics.html#the-has-many-association
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.