- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个问题,一开始看起来并不难,但实际上我无法解决。我正在尝试将 Refinery 用作应用程序的 CMS。我想将 Refinery 用户和其他类型的用户分开,称他们为 mktgeistusers,他们需要注册和登录才能访问某些 protected 页面。所以我首先创建了一个没有精炼厂的应用程序(只有设计)以确保一切正常(从身份验证方面)。这里没有问题。下一步是通过执行以下操作来创建全新的 Refinery 安装:
refinerycms testRefineryPlusDevise -d mysql
add other refinery gems to the Gemfile
gem 'refinerycms-i18n', '~> 2.0.0'
gem 'refinerycms-blog', '~> 2.0.0'
gem 'refinerycms-inquiries', '~> 2.0.0'
gem 'refinerycms-search', '~> 2.0.0', :git => 'git://github.com/refinery/refinerycms-search.git', :branch => '2-0-stable'
gem 'refinerycms-page-images', '~> 2.0.0'
gem "refinerycms-news", '~> 2.0.0'
bundle update
rails generate refinery:blog
rails generate refinery:inquiries
rails generate refinery:news
rake db:migrate
它创造了应有的一切。当我继续创建新类型的用户时,问题就开始了:
rails generate devise Mktgeistuser
invoke active_record
create db/migrate/20121019201721_devise_create_mktgeistusers.rb
create app/models/mktgeistuser.rb
invoke test_unit
create test/unit/mktgeistuser_test.rb
create test/fixtures/mktgeistusers.yml
insert app/models/mktgeistuser.rb
route devise_for :mktgeistusers
rake db:migrate
用户现已创建。然后我添加了一个静态页面,用于放置登录/注销链接进行测试,并添加了以下路由:
#devise_for :mktgeistusers
devise_for :mktgeistuser, :controllers=>{:sessions=>"mktgeistuser/sessions"} do
match '/mktgeistuser/sign_out', :action=>"destroy", :controller=>"devise/sessions"
match '/mktgeistuser/sign_in', :action=>"new", :controller=>"devise/sessions"
match '/mktgeistuser/sign_up', :action=>"new", :controller=>"devise/registrations"
end
root :to => "static#home"
default of "refinery"
mount Refinery::Core::Engine, :at => '/refinery'
在 static/home 中是这样的:
<h1>Static#home</h1>
<p>
Find me in app/views/static/home.html.erb
</p>
<div id="user_nav">
<% if mktgeistuser_signed_in? %>
Signed in as <%= current_mktgeistuser.email %>.
<%= link_to "Sign out", destroy_mktgeistuser_session_path, :method => :delete %>
<% else %>
<%= link_to 'Register', new_mktgeistuser_registration_path %> or <%= link_to 'Sign in', new_mktgeistuser_session_path %>
<% end %>
</div>
<%= javascript_include_tag :defaults %>
问题是当 refinery 运行时,应用程序找不到 mktgeist 用户的 Devise 助手:当我点击登录/注册链接时,我得到
NoMethodError in Devise/sessions#new
Showing /home/mike/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/app/views/devise/sessions/new.html.erb where line #3 raised:
undefined method `mktgeistuser_session_path' for #<ActionDispatch::Routing::RoutesProxy:0xdeb1d6c>
Extracted source (around line #3):
1: <h2>Sign in</h2>
2:
3:
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
4: <div><%= f.label :email %><br />
5: <%= f.email_field :email %></div>
6:
同理,也找不到destroy_mktgeistuser_session_path new_mktgeistuser_registration_path 和new_mktgeistuser_session_path。你知道如何解决这个问题吗?
顺便说一句,这是一个 rake 路由输出
static_home GET /static/home(.:format) static#home
mktgeistuser_sign_out /mktgeistuser/sign_out(.:format) devise/sessions#destroy
mktgeistuser_sign_in /mktgeistuser/sign_in(.:format) devise/sessions#new
mktgeistuser_sign_up /mktgeistuser/sign_up(.:format) devise/registrations#new
new_mktgeistuser_session GET /mktgeistuser/sign_in(.:format) mktgeistuser/sessions#new
mktgeistuser_session POST /mktgeistuser/sign_in(.:format) mktgeistuser/sessions#create
destroy_mktgeistuser_session DELETE /mktgeistuser/sign_out(.:format) mktgeistuser/sessions#destroy
mktgeistuser_password POST /mktgeistuser/password(.:format) devise/passwords#create
new_mktgeistuser_password GET /mktgeistuser/password/new(.:format) devise/passwords#new
edit_mktgeistuser_password GET /mktgeistuser/password/edit(.:format) devise/passwords#edit
PUT /mktgeistuser/password(.:format) devise/passwords#update
cancel_mktgeistuser_registration GET /mktgeistuser/cancel(.:format) devise/registrations#cancel
mktgeistuser_registration POST /mktgeistuser(.:format) devise/registrations#create
new_mktgeistuser_registration GET /mktgeistuser/sign_up(.:format) devise/registrations#new
edit_mktgeistuser_registration GET /mktgeistuser/edit(.:format) devise/registrations#edit
PUT /mktgeistuser(.:format) devise/registrations#update
DELETE /mktgeistuser(.:format) devise/registrations#destroy
root / static#home
refinery / Refinery::Core::Engine
Routes for Refinery::Core::Engine:
/system/resources/*dragonfly(.:format) <Dragonfly::App name=:refinery_resource
s >
insert_admin_resources GET /refinery/resources/insert(.:format) refinery/admin/resources#insert
admin_resources GET /refinery/resources(.:format) refinery/admin/resources#index
POST /refinery/resources(.:format) refinery/admin/resources#create
new_admin_resource GET /refinery/resources/new(.:format) refinery/admin/resources#new
edit_admin_resource GET /refinery/resources/:id/edit(.:format) refinery/admin/resources#edit
admin_resource PUT /refinery/resources/:id(.:format) refinery/admin/resources#update
DELETE /refinery/resources/:id(.:format) refinery/admin/resources#destroy
/system/images/*dragonfly(.:format) <Dragonfly::App name=:refinery_images >
insert_admin_images GET /refinery/images/insert(.:format) refinery/admin/images#insert
admin_images GET /refinery/images(.:format) refinery/admin/images#index
POST /refinery/images(.:format) refinery/admin/images#create
new_admin_image GET /refinery/images/new(.:format) refinery/admin/images#new
edit_admin_image GET /refinery/images/:id/edit(.:format) refinery/admin/images#edit
admin_image PUT /refinery/images/:id(.:format) refinery/admin/images#update
DELETE /refinery/images/:id(.:format) refinery/admin/images#destroy
admin_dashboard GET /refinery/dashboard(.:format) refinery/admin/dashboard#index
admin_disable_upgrade_message /refinery/disable_upgrade_message(.:format) refinery/admin/dashboard#disable_upgrad
e_message
/system/resources/*dragonfly(.:format) <Dragonfly::App name=:refinery_resource
s >
GET /refinery/resources/insert(.:format) refinery/admin/resources#insert
GET /refinery/resources(.:format) refinery/admin/resources#index
POST /refinery/resources(.:format) refinery/admin/resources#create
GET /refinery/resources/new(.:format) refinery/admin/resources#new
GET /refinery/resources/:id/edit(.:format) refinery/admin/resources#edit
PUT /refinery/resources/:id(.:format) refinery/admin/resources#update
DELETE /refinery/resources/:id(.:format) refinery/admin/resources#destroy
/system/images/*dragonfly(.:format) <Dragonfly::App name=:refinery_images >
GET /refinery/images/insert(.:format) refinery/admin/images#insert
GET /refinery/images(.:format) refinery/admin/images#index
POST /refinery/images(.:format) refinery/admin/images#create
GET /refinery/images/new(.:format) refinery/admin/images#new
GET /refinery/images/:id/edit(.:format) refinery/admin/images#edit
PUT /refinery/images/:id(.:format) refinery/admin/images#update
DELETE /refinery/images/:id(.:format) refinery/admin/images#destroy
admin_dashboard GET /refinery/dashboard(.:format) refinery/admin/dashboard#index
admin_disable_upgrade_message /refinery/disable_upgrade_message(.:format) refinery/admin/dashboard#disable_upgrad
e_message
/system/resources/*dragonfly(.:format) <Dragonfly::App name=:refinery_resource
s >
GET /refinery/resources/insert(.:format) refinery/admin/resources#insert
GET /refinery/resources(.:format) refinery/admin/resources#index
POST /refinery/resources(.:format) refinery/admin/resources#create
GET /refinery/resources/new(.:format) refinery/admin/resources#new
GET /refinery/resources/:id/edit(.:format) refinery/admin/resources#edit
PUT /refinery/resources/:id(.:format) refinery/admin/resources#update
DELETE /refinery/resources/:id(.:format) refinery/admin/resources#destroy
/system/images/*dragonfly(.:format) <Dragonfly::App name=:refinery_images >
GET /refinery/images/insert(.:format) refinery/admin/images#insert
GET /refinery/images(.:format) refinery/admin/images#index
POST /refinery/images(.:format) refinery/admin/images#create
GET /refinery/images/new(.:format) refinery/admin/images#new
GET /refinery/images/:id/edit(.:format) refinery/admin/images#edit
PUT /refinery/images/:id(.:format) refinery/admin/images#update
DELETE /refinery/images/:id(.:format) refinery/admin/images#destroy
admin_dashboard GET /refinery/dashboard(.:format) refinery/admin/dashboard#index
admin_disable_upgrade_message /refinery/disable_upgrade_message(.:format) refinery/admin/dashboard#disable_upgrad
e_message
news_root /news(.:format) refinery/news/items#index
news_items_archive GET /news/archive/:year(/:month)(.:format) refinery/news/items#archive
news_items GET /news(.:format) refinery/news/items#index
news_item GET /news/:id(.:format) refinery/news/items#show
news_admin_root /refinery/news(.:format) refinery/news/admin/items#index
news_admin_items GET /refinery/news/items(.:format) refinery/news/admin/items#index
POST /refinery/news/items(.:format) refinery/news/admin/items#create
new_news_admin_item GET /refinery/news/items/new(.:format) refinery/news/admin/items#new
edit_news_admin_item GET /refinery/news/items/:id/edit(.:format) refinery/news/admin/items#edit
news_admin_item PUT /refinery/news/items/:id(.:format) refinery/news/admin/items#update
DELETE /refinery/news/items/:id(.:format) refinery/news/admin/items#destroy
search /search(.:format) refinery/search#show
inquiries_new_inquiry GET /contact(.:format) refinery/inquiries/inquiries#new
thank_you_inquiries_inquiries GET /contact/thank_you(.:format) refinery/inquiries/inquiries#thank_you
inquiries_inquiries POST /contact(.:format) refinery/inquiries/inquiries#create
spam_inquiries_admin_inquiries GET /refinery/inquiries/spam(.:format) refinery/inquiries/admin/inquiries#spam
toggle_spam_inquiries_admin_inquiry GET /refinery/inquiries/:id/toggle_spam(.:format) refinery/inquiries/admin/inquiries#togg
le_spam
inquiries_admin_inquiries GET /refinery/inquiries(.:format) refinery/inquiries/admin/inquiries#inde
x
inquiries_admin_inquiry GET /refinery/inquiries/:id(.:format) refinery/inquiries/admin/inquiries#show
DELETE /refinery/inquiries/:id(.:format) refinery/inquiries/admin/inquiries#dest
roy
edit_inquiries_admin_setting GET /refinery/inquiries/settings/:id/edit(.:format) refinery/inquiries/admin/settings#edit
inquiries_admin_setting PUT /refinery/inquiries/settings/:id(.:format) refinery/inquiries/admin/settings#updat
e
blog_root /blog(.:format) refinery/blog/posts#index
blog_post GET /blog/posts/:id(.:format) refinery/blog/posts#show
blog_rss_feed /blog/feed.rss(.:format) refinery/blog/posts#index {:format=>"rs
s"}
blog_category /blog/categories/:id(.:format) refinery/blog/categories#show
blog_comments /blog/:id/comments(.:format)
等等
非常感谢您的任何帮助或建议!
顺便说一句,我正在使用 Devise 2.0.4
最佳答案
你需要改变
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) %>
到
<%= form_for(resource, :as => resource_name, :url => mktgeistuser_session_path) %>
关于authentication - Refinerycms + 设计 : custom user can't find the devise helpers (how to add a separate devise authentication)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12986818/
我已将 Devise 设置为允许使用电子邮件或用户名登录。使用您的用户名,您可以拥有一个个性网址,如下所示:vanity.com/username。因此,我的用户模型具有 attr_accessibl
我有个类似的问题。我正在使用sendmail选项,并继续出现错误 “发送邮件需要使用SMTP发件人地址。设置邮件 smtp_envelope_from,return_path,发件人或地址。” 我已经
我在为我的用户表做种子时遇到问题。 (rails 3.2.6,jruby 1.6.7.2,devise 2.1.2) 这是一个非常通用的用户表,由“rails generate devise User
我为公司设计了一个设计。我做了一个表用户,希望我想存储用户信息密码等。当用户注册时,我希望它创建一个新用户和公司的关联。 我的公司模型:has_one:用户我的用户模型:Belongs_to: 公司
我目前正在从我们的应用程序中删除 IP 日志记录,我想知道使用 Devise 执行此操作的最佳方法是什么? 最佳答案 你的答案看起来不错,但如果你只想跟踪特定用户的 IP,一个(不那么冗长但可能更令人
我有一个包含 Devise (2.2.3) 和 Active Admin (0.5.1) 的应用程序,我先安装了 Devise,然后安装了 Active Admin。整个应用程序需要登录,所以在我的应
我有一个包含 Devise (2.2.3) 和 Active Admin (0.5.1) 的应用程序,我先安装了 Devise,然后安装了 Active Admin。整个应用程序需要登录,所以在我的应
我在 API 模式下使用 Rails,使用 Devise 和 Devise JWT(用于 API)和 ActiveAdmin。我一切正常,但我一直在构建 API Controller ,现在 Acti
在使用 Devise TestHelpers 的文档中,它声明使用诸如... @request.env["devise.mapping"] = Devise.mappings[:admin] 或者 @
许多程序员使用 devise 作为他们的身份验证解决方案,我想听听他们的建议: Devise 已经过测试,但我想知道是否有我自己要测试的东西(集成/单元/功能测试?),以根据我的知识进行标准设计集成(
我正在尝试通过 JSON 注册设备用户,但一直收到 ActiveModel::ForbiddenAttributesError class Api::V1::RegistrationsControll
我正在使用 Rails 4.0.2 和 Devise 3.2.2 来处理用户注册/身份验证。 我已经用谷歌搜索并在 stackoverflow 上搜索答案,但找不到可以回答我的问题的东西。 下面的代码
我正在使用 ruby 2.2.3 和 rails 4.2.5。我无法在我的项目上运行 rails generate devise:install。 Bundler 抛出错误。错误如下 rails
我正在使用设计和 devise-basecamper用于使用我的基于子域的 Web 应用程序进行身份验证。 我想允许 super 用户访问任何帐户(基本上是任何子域)。 我不确定我将如何实现这一点,以
我正在为我的应用程序实现设计邮件程序,我已完成以下步骤: 在模型中: class User "smtp.gmail.com", :port => 587, :domain =
我在 SO 上找到了类似的线程,但没有一个帮助我解决了这个问题。我的路线如下: devise_for :users do post '/users' => 'registrations#cre
编辑 2:看起来对我来说一个快速的临时修复是在我的 link_to_unless_current 和 current_page 方法中的 Controller 名称前面添加一个正斜杠“/”。例如 '
由于无法控制的原因,我无法在当前项目中使用RSpec进行测试。我正在尝试测试“设计重置密码”,但似乎无法提出有用的建议。 这是我到目前为止的内容: require 'test_helper' clas
我有一个问题,一开始看起来并不难,但实际上我无法解决。我正在尝试将 Refinery 用作应用程序的 CMS。我想将 Refinery 用户和其他类型的用户分开,称他们为 mktgeistusers,
我想自定义以下由devise提供的flash msg 在 devise.en.yml 文件中: devise: failure: unconfirmed: 'You have to
我是一名优秀的程序员,十分优秀!