Flash message doesn't show up

In the controller method I have the following:

def create
@adv = Adv.new(params[:adv])
@adv.save
flash[:notice] = “Advertisement successfully created”
redirect_to “/advs/#{@adv.id}”
end

When I create a new “Adv”, I DON’T get the message: “Advertisement
successfully created”

Why is that? What am I missing?

Thanks.

On 21 August 2010 18:35, Abder-Rahman A. [email protected] wrote:

In the controller method I have the following:

def create
@adv = Adv.new(params[:adv])
@adv.save
flash[:notice] = “Advertisement successfully created”
redirect_to “/advs/#{@adv.id}”

The code here is setting up the flash but you have to have code in the
view to display it. What have you got in the view that you are showing
after the redirect?

Colin

In View have you added <%= flash[:notice] %>
and <%= javascript_include_tag :defaults %>

Thanks a lot everyone.

You are correct:

Yes, I have added “<%= flash[:notice] %>” in “application.html.erb”

I just want to ask, how can we make that notice with a different color
and background? Should we do this manually by HTML for example?

Thanks.

Bill W. wrote:

On Sun, Aug 22, 2010 at 8:26 AM, Abder-Rahman A. [email protected]
wrote:

I just want to ask, how can we make that notice with a different color
and background? Should we do this manually by HTML for example?

Change the values in the selector in application.css

HTH,
Bill

I made some changes in “application.html.erb” as follows:

<%= flash[:notice] %>

And it did what I was looking for.

Thanks.

On Sun, Aug 22, 2010 at 9:21 AM, Abder-Rahman A. [email protected]
wrote:

I made some changes in “application.html.erb” as follows:

<%= flash[:notice] %>

And it did what I was looking for.

Inline styling will certainly work but it has very much fallen out of
favor. You will do yourself a favor, professional reputation-wise, by
learning to use css selectors.

Best regards,
Bill

On Sun, Aug 22, 2010 at 8:26 AM, Abder-Rahman A. [email protected]
wrote:

I just want to ask, how can we make that notice with a different color
and background? Should we do this manually by HTML for example?

Change the values in the selector in application.css

HTH,
Bill