简体   繁体   English

我该如何在用户搜索事件并保存感兴趣的事件的地方建模我的Rails应用程序?

[英]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.

相关问题 如何编写 Rails finder 方法来搜索我的模型,其中 has_many 没有特定属性? - How do I write a Rails finder method to search for my model where the has_many has no particular attribute? 在Rails应用程序中,我的Javascript应该在哪里,以及如何调用它? - In a Rails application, where should my Javascript be and how do I call it? 如何从Rails中的模型保存 - how do I save from a model in rails 在Rails应用程序中放置模型搜索逻辑的位置? - Where to put model search logic in a Rails application? 如何在团队,用户和组织之间将我的模型与Rails相关联? - How do i associate my model in rails between teams, users and organizations? 如何在Rails应用程序中运行Rails G模型/ Rake db:migrate - How do I run rails g model / rake db:migrate within my rails application 如何在Rails中为匿名用户保存临时数据 - How do I save temporary data for anonymous users in Rails Rails:如何在我的模型中调用`self.save`并将其保留在数据库中? - Rails: How do I call `self.save` in my model and have it persist in the database? 如何将用户模型添加到我的应用程序中,以便数据在我的Rails应用程序中是“用户”特定的 - How do I add a user model to my application so data is “user” specific in my Rails app 如何在应用程序中更新Rails - How do I update rails in my application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM