我想在登录/注销时删除Devise的set_flash_message,所以我创建了 我自己的sessions_controller,从devise's逐字复制。我将视图复制到app / views / sessions,并更改了路径。现在,当我登录时,它会将我重定向回登录页面。 rails日志显示
Processing by SessionsController#new as HTML
当我使用内置会话控制器时,它不显示。有任何想法吗?
我可以在没有覆盖控制器的情况下解决这个问题,但我怀疑无论如何我都会想要这样做并且遇到同样的问题。何塞不知道。我该如何解决这个问题?
app / controllers / sessions_controller.rb:与/Users/jay/.rvm/gems/ruby-1.9.2-p180/gems/devise-1.2.1/app/controllers/devise/sessions_controller.rb相同。< / p>
配置/ routes.rb中:
devise_for :users, :controllers => { :sessions => :sessions }
...
使用我的控制器副本输出rails:
Started POST "/users/sign_in" for 127.0.0.1 at 2011-04-07 16:15:54
-0400
Processing by SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"o8JIe+jGu
+xiuuIbAZc6kg6aD6TKk86rKBydeFxLH40=",
"user"=>{"email"=>"jlev...@tiptap.com", "password"=>"[FILTERED]",
"remember_me"=>"0"}, "commit"=>"Sign in"}
PK and serial sequence (1.7ms) SELECT attr.attname, seq.relname
FROM pg_class seq,
pg_attribute attr,
pg_depend dep,
pg_namespace name,
pg_constraint cons
WHERE seq.oid = dep.objid
AND seq.relkind = 'S'
AND attr.attrelid = dep.refobjid
AND attr.attnum = dep.refobjsubid
AND attr.attrelid = cons.conrelid
AND attr.attnum = cons.conkey[1]
AND cons.contype = 'p'
AND dep.refobjid = '"badges_users"'::regclass
PK and custom sequence (0.8ms) SELECT attr.attname,
CASE
WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN
substr(split_part(def.adsrc, '''', 2),
strpos(split_part(def.adsrc, '''', 2), '.')+1)
ELSE split_part(def.adsrc, '''', 2)
END
FROM pg_class t
JOIN pg_attribute attr ON (t.oid = attrelid)
JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum)
JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1])
WHERE t.oid = '"badges_users"'::regclass
AND cons.contype = 'p'
AND def.adsrc ~* 'nextval'
Completed in 101ms
Processing by SessionsController#new as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"o8JIe+jGu
+xiuuIbAZc6kg6aD6TKk86rKBydeFxLH40=",
"user"=>{"email"=>"jlev...@tiptap.com", "password"=>"[FILTERED]",
"remember_me"=>"0"}, "commit"=>"Sign in"}
SQL (0.9ms) SELECT a.attname, format_type(a.atttypid,
a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
Rendered devise/shared/_links.erb (1.6ms)
Rendered sessions/new.html.erb within layouts/devise/sessions (9.1ms)
Completed 200 OK in 162ms (Views: 13.4ms | ActiveRecord: 4.8ms)
使用内置控制器输出rails:
Started POST "/users/sign_in" for 127.0.0.1 at 2011-04-08 10:41:35 -0400
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"m3gKBQM8We9oHvsLjkPA8O/wQEJeZibRtY0tDgqZHxk=", "user"=>{"email"=>"jlevitt@tiptap.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
PK and serial sequence (1.8ms) SELECT attr.attname, seq.relname
FROM pg_class seq,
pg_attribute attr,
pg_depend dep,
pg_namespace name,
pg_constraint cons
WHERE seq.oid = dep.objid
AND seq.relkind = 'S'
AND attr.attrelid = dep.refobjid
AND attr.attnum = dep.refobjsubid
AND attr.attrelid = cons.conrelid
AND attr.attnum = cons.conkey[1]
AND cons.contype = 'p'
AND dep.refobjid = '"badges_users"'::regclass
PK and custom sequence (0.7ms) SELECT attr.attname,
CASE
WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN
substr(split_part(def.adsrc, '''', 2),
strpos(split_part(def.adsrc, '''', 2), '.')+1)
ELSE split_part(def.adsrc, '''', 2)
END
FROM pg_class t
JOIN pg_attribute attr ON (t.oid = attrelid)
JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum)
JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1])
WHERE t.oid = '"badges_users"'::regclass
AND cons.contype = 'p'
AND def.adsrc ~* 'nextval'
SQL (0.7ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'jlevitt@tiptap.com' LIMIT 1
SQL (0.6ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
SQL (0.1ms) BEGIN
AREL (0.3ms) UPDATE "users" SET "last_sign_in_at" = '2011-04-08 13:12:42.161090', "current_sign_in_at" = '2011-04-08 14:41:35.486567', "sign_in_count" = 17, "updated_at" = '2011-04-08 14:41:35.487136' WHERE "users"."id" = 6
SQL (0.3ms) COMMIT
Redirected to http://localhost:3000/
Completed 302 Found in 302ms
答案 0 :(得分:1)
如果您只想自定义设计使用的消息,只需编辑devise.en.yml文件
<强>配置/区域设置/ devise.en.yml 强>
en:
...
devise:
sessions:
signed_in: 'Signed in successfully.'
signed_out: 'Signed out successfully.'