How can I use another view if a specific parameter is given?
I have an actio开发者_如何学Cn called new
:
def new
@bookmark = Bookmark.new
respond_to do |format|
format.html # new.html.erb
format.mobile
format.xml { render :xml => @bookmark }
end
end
Now, when the param[:widget] == "true"
, I want to use a lay-out other than application.html.haml
, and I want to show another view than new.html.haml
called new_widget.html.haml
.
How can I do this? Thanks.
Something like this?
def new
@bookmark = Bookmark.new
if params[:widget] == "true"
render 'new_widget.html.haml', :layout => 'path/to/other/layout'
return
end
respond_to do |format|
format.html # new.html.erb
format.mobile
format.xml { render :xml => @bookmark }
end
end
精彩评论