开发者

Can I do a wildcard with 'responds-to format' in Rails3?

开发者 https://www.devze.com 2023-02-19 09:15 出处:网络
Consider the following code: respond_to do |format| format.js{ render :layout => false } format.xml { head :ok }

Consider the following code:

respond_to do |format|
  format.js  { render :layout => false }
  format.xml { head :ok }
end

Now I know you can specify a whole bunch of formats, but is there a way to specify all other formats (in this case other than .jx and .xml) to save me from having to specify every specific format explicitly?

I guess I kind of want an "if-else" type condition. Is this possible with respond_to do |fo开发者_开发百科rmat|?


Good answer for you here: Can Ruby on Rails's respond_to return a line when the format is not supported? although they posed their question differently.
hth
Perry

0

精彩评论

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

关注公众号