开发者

how to display an alternate message ,if particular record is not available?

开发者 https://www.devze.com 2023-03-14 09:47 出处:网络
presently i am playing with rails3.Can it possible to show a message like\"So开发者_开发技巧rry , this data is not available\", in view if we do not have that data in record.This is a way to...

presently i am playing with rails3.Can it possible to show a message like"So开发者_开发技巧rry , this data is not available", in view if we do not have that data in record.


This is a way to...

class ModelController < ApplicationController

  def show
    respond_to do |format|
      begin
        @model = Model.find(params[:id])
      rescue ActiveRecord::RecordNotFound 
        format.html { render :text => "Sorry , this data is not available" }
      end
    end
  end

end
0

精彩评论

暂无评论...
验证码 换一张
取 消