看了,知道了缓存会过期清除,但是还是不懂怎么在没过期前清除它..
因为这个缓存我是这样写的:
<% cache("#{CACHE_PREFIX}/layout/right", :expires_in => 1.day) do %>
它检测不到是否有内容更新
#6 楼 @hw676018683 但是不能等到过期时间才清呀
之所以要清除片段缓存,是因为我有个右边栏的‘热门文章’、‘最新评论’的设计
一有文章发布或有评论则删除右边栏 _right.html
里的片段缓存,然后重新建立新的缓存
我的 cache 语句是这样的,写在开头:
<% cache("#{CACHE_PREFIX}/layout/right", :expires_in => 1.day) do %>
等等等---
求教。
比如说我的片段缓存地址是 views/LOL/layout/right/22e88d0ae992a3655ac6bd7ca224fc78
有什么方法,在我知道缓存是在 views/LOL/layout/right/
下面的情况下,清理这一缓存?
我也觉得少,相对于 passenger 少太多了
哇塞,人气好高啊
迫不得已也设置了config.assets.compile = true
Did anybody fix it?
666666
先暂时换回原来的 rails 4.2 用着先..
顶下
log 文件里好像也是表示没有更新到 follower_ids
Started POST "/test/follow" for 127.0.0.1 at 2016-04-16 17:05:15 +0800
Processing by UsersController#follow as HTML
Parameters: {"id"=>"test"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 9]]
(0.1ms) BEGIN
User Exists (0.4ms) SELECT 1 AS one FROM "users" WHERE ("users"."name" = 'msl' AND "users"."id" != 9) LIMIT 1
SQL (0.4ms) UPDATE "users" SET "following_ids" = $1, "updated_at" = $2 WHERE "users"."id" = $3 [["following_ids", "{1,6}"], ["updated_at", "2016-04-16 09:05:15.507663"], ["id", 9]]
User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE ("users"."name" = 'test' AND "users"."id" != 6) LIMIT 1
(16.7ms) COMMIT
Redirected to http://localhost:3000/test
Completed 302 Found in 37ms (ActiveRecord: 18.5ms)
#5 楼 @imconfused 你这么一说,噢,好像知道了什么了
不明白为什么,routes 文件里面是已经有root to: 'welcome#index'
了
Started GET "/notifications" for 127.0.0.1 at 2016-04-16 13:57:08 +0800
Processing by Notifications::NotificationsController#index as HTML
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 9]]
Notification Load (0.4ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."user_id" = $1 ORDER BY id desc LIMIT 20 OFFSET 0 [["user_id", 9]]
Rendered notifications/notifications/index.html.erb within layouts/application (4.9ms)
Completed 500 Internal Server Error in 128ms (ActiveRecord: 0.6ms)
ActionView::Template::Error (undefined local variable or method `root_path' for #<#<Class:0x007f3740d9c348>:0x007f37410efd88>):
17: <% else %>
18: <%= user_name_tag(current_user) %>(管理员)<% end %>
19: <%= link_to '首页', root_path %>
20: <%= link_to '编辑资料', edit_user_registration_path %>
21: <% if admin? %>
22: <%= link_to '撰写公告', edit_announcement_path %>
23: <% end %>
app/views/layouts/application.html.erb:20:in `_app_views_layouts_application_html_erb__959845113685053431_69937645716180'
不过不知道为什么在我的 shell 里运行这句代码时:
rails g notifications:install
会出现这个:
Adding Homeland initializer (config/initializers/notifications.rb)...
create config/initializers/notifications.rb
Adding model (notification.rb)...
create app/models/notification.rb
Error: Command 'notifications:install:migrations' not recognized
Did you mean: `$ rake notifications:install:migrations` ?
Usage: rails COMMAND [ARGS]
The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
dbconsole Start a console for the database specified in config/database.yml
(short-cut alias: "db")
new Create a new Rails application. "rails new my_app" creates a
new application called MyApp in "./my_app"
In addition to those, there are:
destroy Undo code generated with "generate" (short-cut alias: "d")
plugin new Generates skeleton for developing a Rails plugin
runner Run a piece of code in the application environment (short-cut alias: "r")
All commands can be run with -h (or --help) for more information.
猴赛雷