如
200 => Found
403 => Not authorized
404 => Not found
Run Code Online (Sandbox Code Playgroud)
我猜Rails 3已经有了这个功能,因为你可以传递哈希render :status => :not_found,我只是找不到方法来做其他方式.如果没有人知道可以做到这一点的宝石?
rspec中的事务夹具阻止调用after_commit,但即使我禁用它们也是如此
RSpec.configure do |config|
config.use_transactional_fixtures = false
end
Run Code Online (Sandbox Code Playgroud)
在after_commit callback不运行.
这是一个带有最新版本的rspec/rails的rails应用程序: git://github.com/sheabarton/after_commit_demo.git
在firebug中,您可以使用该cd命令将控制台上下文更改为iframe.我在开发一个facebook应用程序来调试我在iframe中的javascript时需要这个.
你是如何在谷歌浏览器中做到这一点的?
在Mongoid中,我如何实现ActiveRecord :through =>提供的相同功能?
class Advertiser
include Mongoid::Document
embeds_many :campaigns
# how would I do this
embeds_many :advertisements, :through => :campaigns
end
class Campaign
embedded_in :advertiser
embeds_many :advertisements
end
class Advertisement
embedded_in :campaign
# or this?
embedded_in :advertiser, :through => :campaign
end
Run Code Online (Sandbox Code Playgroud)
那么能够做到
Advertiser.first.advertisements
和
Advertisement.first.advertiser
Advertiser.campaigns.collect{|campaign| campaign.advertisement} 不是一种选择
怎么样,我怎么用references_many/ referenced_in?
我有一个ActiveRecord模型Media这应该能够存储有关不同类型的媒体(类似结构化信息Media::Book,Media::Movie,Media::Music).但是,每个子类都有独特的方法.
# TABLE medias
# string :title
# string :description
# integer :media_type
class Media < ActiveRecord::Base
end
class Media
class Book < Media
def reviews
GoogleBooks.search(name).get_reviews
end
end
class Movie < Media
def reviews
IMDB.search_movies(name).reviews
end
end
class Music < Media
def reviews
Lastfm.search(name).comments
end
def music_video
Youtube.search(name).first.embed_html
end
end
end
Run Code Online (Sandbox Code Playgroud)
如果我使用Media::Book.new("Harry Potter").reviews,这将有效,但我希望能够使用
Media.find("Harry Potter")
=> Media::Book
Run Code Online (Sandbox Code Playgroud)
和
Media.find("Harry Potter").reviews
Run Code Online (Sandbox Code Playgroud)
我知道我应该使用media_type来实现这一点,但我不知道,如果那里有一个更好的方式来做到这一点不是覆盖每一个ActiveRecord的数据库接口方法(User.medias,find,find_by_etc, …
我试图通过两个触摸屏点击一个元素,然后单击,通过事件touchStart和click.
如何将这两个事件连接到一个Ember视图?
我试过了:
{{action "itsClicked" on="click touchMove"}}
{{action "itsClicked" on="click, touchMove"}}
{{action "itsClicked" on="click"}} {{action "itsClicked" on="touchMove"}}
ruby ×2
activerecord ×1
commit ×1
ember.js ×1
firebug ×1
mongodb ×1
mongoid ×1
rails-models ×1
render ×1
rspec-rails ×1
rspec2 ×1
sti ×1