小编PMP*_*PMP的帖子

友情ID随机网址

我对我的网站使用友好,目前我在网址上显示标题

即: /articles/hello-world

但是当我创建页面时,它会生成一个随机数,以避免重复

即: /articles/75475848

我知道如果我摆脱了友好ID,它会显示数字,但它会

/条/ 1

/条/ 2

等等...

基本上我如何让它显示/articles/23456789(random number)而不是/articles/hello-world

谢谢

friendly-url ruby-on-rails friendly-id

2
推荐指数
1
解决办法
1635
查看次数

Rails SQL 计数

我有一个 Posts 表和一个 Sec_photo 表:

class Post < ActiveRecord::Base
  has_many :sec_photos
Run Code Online (Sandbox Code Playgroud)

我正在尝试做一个高级搜索表单,它posts根据它们的总和找到sec_photos@posts = @posts.where(:sec_photos.count > 2)失败,我在网上查看并尝试了许多其他解决方案,但似乎都不起作用。

有人有什么想法吗?

PS:该行必须采用以下形式@posts = @posts.where与其他条件相符。

高级搜索可搜索其他字段,例如category_id 和location_id 等

@posts = Post.all
     @posts = @posts.where('category_id = ?', @advanced_search.category_search) if @advanced_search.category_search.present?
     @posts = @posts.where('location_id = ?', @advanced_search.location_search) if @advanced_search.location_search.present?
     @posts = @posts.where("strftime('%m %Y', created_at) = ?", @advanced_search.newdate_search.strftime('%m %Y')) if @advanced_search.newdate_search.present?
Run Code Online (Sandbox Code Playgroud)

最后一个选项是显示 sec_photos 大于 2 或小于 2 的帖子

sql sqlite ruby-on-rails count

2
推荐指数
1
解决办法
4390
查看次数

Ruby on Rails最大长度视图

所以我有我的/ articles的index.html.erb,我有我的所有文章的列表及其描述.那么在文章的show.html.erb中,描述是500个字符的长度.如何在index.html.erb中只显示250个字符,然后阅读更多链接?

ruby ruby-on-rails

0
推荐指数
1
解决办法
755
查看次数

Heroku App总是崩溃

自从我的heroku应用程序开始崩溃以来,现在已经过了48个小时.我真的不知道是什么让它崩溃了,我已经尝试重新启动它,更改动力学和跑步heroku run rake db:migrate但这些似乎都不起作用.

这些是我的heroku日志

at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=serene-savannah-7550.herokuapp.com fwd="81.34.154.155" dyno= connect= service= status=503 bytes=
2013-08-27T12:51:50+00:00 app[heroku-postgres]: source=HEROKU_POSTGRESQL_BLACK measure.current_transaction=26940 measure.db_size=56841336bytes measure.tables=23 measure.active-connections=3 measure.waiting-connections=0 measure.index-cache-hit-rate=0.85317 measure.table-cache-hit-rate=0.99704
2013-08-27T12:52:45+00:00 app[heroku-postgres]: source=HEROKU_POSTGRESQL_BLACK measure.current_transaction=26940 measure.db_size=56841336bytes measure.tables=23 measure.active-connections=3 measure.waiting-connections=0 measure.index-cache-hit-rate=0.85317 measure.table-cache-hit-rate=0.99704
2013-08-27T12:53:34.027760+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=www.website.com fwd="81.34.154.155" dyno= connect= service= status=503 bytes=
2013-08-27T12:54:35.129270+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=www.website.com fwd="81.34.154.155" dyno= connect= service= status=503 bytes=
2013-08-27T12:54:36+00:00 app[heroku-postgres]: source=HEROKU_POSTGRESQL_BLACK measure.current_transaction=26940 measure.db_size=56841336bytes measure.tables=23 measure.active-connections=3 measure.waiting-connections=0 measure.index-cache-hit-rate=0.99998 measure.table-cache-hit-rate=1 …
Run Code Online (Sandbox Code Playgroud)

crash postgresql ruby-on-rails heroku

0
推荐指数
1
解决办法
2931
查看次数