如果我不正确处理观点,生产环境就显示500个。
<%=图像_tag post.user.image_url %>
这可以
<%=图像_tag post.user.image_url if post.user && post.user.image_url %>
但是,我几乎无所顾忌,并数次放弃这一问题。
我如何防止这种情况? 在生产环境中,我如何使用<代码><%=图像_tag nil %>,而不提500?
如果我不正确处理观点,生产环境就显示500个。
<%=图像_tag post.user.image_url %>
这可以
<%=图像_tag post.user.image_url if post.user && post.user.image_url %>
但是,我几乎无所顾忌,并数次放弃这一问题。
我如何防止这种情况? 在生产环境中,我如何使用<代码><%=图像_tag nil %>,而不提500?
你们可以这样写一个助手:
module ApplicationHelper
def safe_image_tag(source, options = {})
source ||= "default.jpg"
image_tag(source, options)
end
end
或者直截了<代码>nil。 您必须做的任何工作,以防出现错误。
Having a hard time figuring out how to make SASS, not SCSS, as the default for stylesheets. I ve tried making a sass_config.rb file with this: Sass::Plugin.options[:syntax] = :sass Sass::Plugin....
因此,由于所有这一切都涉及到利用美国司法和司法局从铁路3.1号中删除,我很想知道,我将如何在一页上更新相对大量的html。 在我只作部分发言之前......
How do you upgrade from Rails 3 to Rails 3.1 beta?
If you install Ruby on Rails 3.1 the gem execjs gets installed by default. I excluded CoffeeScript, because I thought it needed execjs, but execjs wants to be installed anyway. Is execjs now a ...
There are a number of examples on the Web (such as http://techoctave.com/c7/posts/32-create-an-rss-feed-in-rails) showing how to make a nice RSS feed using Builder. The canonical template is something ...
I m trying to make my actions respond to :html and :json. class GamesController < ApplicationController respond_to :html, :json def index @games = current_user.games respond_with(@...
How should one provide assets in an engine in Rails 3.1? Where should they be located and can they be included automatically? (originally asked by Tomas Celizna)
With SQL I can easily do sub-queries like this User.where(:id => Account.where(..).select(:user_id)) This produces: SELECT * FROM users WHERE id IN (SELECT user_id FROM accounts WHERE ..) How ...