I have this error on my rails logs :
我的rails日志中有这个错误:
Completed 404 Not Found in 11ms
** [Raven] User excluded error: #<ActionController::RoutingError: Not Found>
ActionController::RoutingError (Not Found):
app/controllers/schools_controller.rb:6:in `common_content'
I don't understand why, here is the code :
我不明白为什么,下面是代码:
Show.html.erb
Show.html.erb
<%= link_to "Vérifiés (#{@count_verified})", rate_verified_path, remote: true %>
routes.rb
routes.rb
get '/rate_verified' => 'schools#verified_rating'
schools_controller.rb
schools_controller.rb
before_filter :common_content, :only => [:show, :verified_rating]
def verified_rating
@selected = @ratings.where(:verified => true)
respond_to do |format|
format.js
end
end
verified_rating.js.erb
verified_rating.js.erb
$('#verifie').html("<%= escape_javascript render(:partial => 'rating') %>");
Does someone could help me ?
有人能帮我吗?
EDIT
编辑
the common_content method :
common_content方法:
def common_content
@school = School.where(city_namespace: params[:city], title_namespace: params[:title]).first || raise(ActionController::RoutingError.new('Not Found'))
@rating = Rating.new(params[:rating])
@rating.school_id = @school.id
@ratings = @school.ratings.desc(:created_at)
end
1 个解决方案
#1
2
In first line of common_content
method, we can see:
在common_content方法的第一行中,我们可以看到:
School.where(city_namespace: params[:city], title_namespace: params[:title]).first || raise(ActionController::RoutingError.new('Not Found'))
Because the first part (before ||
) of that code returns nil
the second part is executed, which is:
因为该代码的第一部分(||之前)返回nil,所以执行了第二部分,即:
raise(ActionController::RoutingError.new('Not Found')
So the 404 is raised because no School
record was found.
因为没有发现学校记录,所以404页面被提了出来。
#1
2
In first line of common_content
method, we can see:
在common_content方法的第一行中,我们可以看到:
School.where(city_namespace: params[:city], title_namespace: params[:title]).first || raise(ActionController::RoutingError.new('Not Found'))
Because the first part (before ||
) of that code returns nil
the second part is executed, which is:
因为该代码的第一部分(||之前)返回nil,所以执行了第二部分,即:
raise(ActionController::RoutingError.new('Not Found')
So the 404 is raised because no School
record was found.
因为没有发现学校记录,所以404页面被提了出来。