我希望能够在我的应用程序的主页上显示sign_up表单home#index以及Devise创建的默认页面.
Devise有指令为sign_in页面执行此操作但是如何使用sign_up执行此操作? https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app
谢谢!
我正在寻找一个ActiveRecord查询,这就是我在下面的内容.不幸的是你不能像这样使用OR.什么是最好的执行方式? category_ids是一个整数数组.
.where(:"categories.id" => category_ids).or.where(:"category_relationships.category_id" => category_ids)
Run Code Online (Sandbox Code Playgroud) 我有一张桌子Category可以有很多Businesses和Posts.并且a Business/ Post可以有很多,Categories所以我创建了一个多态的tabled,CategoryRelationship用来打破多对多的关系.
Business 模型有这些关系:
has_many :categories, through: :category_relationships, :source => :category_relationshipable, :source_type => 'Business'
has_many :category_relationships
Run Code Online (Sandbox Code Playgroud)
CategoryRelationship 模型有这些关系:
attr_accessible :category_id, :category_relationship_id, :category_relationship_type
belongs_to :category_relationshipable, polymorphic: true
belongs_to :business
belongs_to :post
belongs_to :category
Run Code Online (Sandbox Code Playgroud)
Category 有这些关系:
has_many :category_relationships
has_many :businesses, through: :category_relationships
has_many :posts, through: :category_relationships
Run Code Online (Sandbox Code Playgroud)
Post会有类似的关系Business.
所以现在当我跑步时Business.first.categories我得到错误:
Business Load (6.1ms) SELECT "businesses".* FROM "businesses" LIMIT 1
Business Load (2.5ms) SELECT "businesses".* FROM "businesses" …Run Code Online (Sandbox Code Playgroud)