adam
1
Hi
I have the following action, that generates a flash message if a blog is
created,
how can I get this message to display in my views?
thanks
# POST /blogs
# POST /blogs.xml
def create
@blog = Blog.new(params[:blog])
respond_to do |format|
if @blog.save
flash[:notice] = 'Blog was successfully created.'
format.html { redirect_to blog_url(@blog) }
format.xml { head :created, :location =>
blog_url(@blog) }
else
format.html { render :action => βnewβ }
format.xml { render :xml => @blog.errors.to_xml }
end
end
end
adam
2
On 5/19/07, adam [email protected] wrote:
thanks
format.html { redirect_to blog_url(@blog) }
Posted via http://www.ruby-forum.com/.
β
Andrei M.
http://andreimaxim.ro
adam
3
I understand that that should pass teh flash hash to the page view,
however when I do somthing like this, nothing is displayed.
If the <%if flash-%> part is removed, an error is shown on most pages
due to a nil object.
any suggestions?
<%if flash-%>
<%if flash[:notice] || flash[:alert] -%>
<%= flash[:notice] || flash[:alert] %>
<% end -%>
<%end-%>
Andrei M. wrote:
On 5/19/07, adam [email protected] wrote:
thanks
format.html { redirect_to blog_url(@blog) }
Posted via http://www.ruby-forum.com/.
β
Andrei M.
http://andreimaxim.ro