Redirect to and notice

I am having an issue where I cannot get the notice to show up on a
custom action in redirect_to

in the routes I have this defined:

match ‘launches/calendar’ => ‘launches#calendar’

in the launches controller I have these entries:
def calendar
@launches = Launch.all
@date = params[:month] ? Date.parse(params[:month]) : Date.today
end

def update
@launch = Launch.find(params[:id])
if @launch.update_attributes(params[:launch])
redirect_to :action =>‘calendar’, :notice => “Successfully
updated launch.”
else
render :action => ‘edit’
end
end

in the calander view file I have the following:

<%= notice %>

but nothing ever shows up.

I am sure I am making a silly mistake here. Just can’t find it.

Thanks,
Dal

did some more research and playing and got it to work by changing:

  redirect_to :action =>'calendar', :notice  => "Successfully

updated launch."

to:

flash[:notice] = “Successfully updated launch.”
redirect_to :action => :calendar

now it seems to work…

On May 4, 4:38pm, dalupus [email protected] wrote:

@date = params[:month] ? Date.parse(params[:month]) : Date.today
end

def update
@launch = Launch.find(params[:id])
if @launch.update_attributes(params[:launch])
redirect_to :action =>‘calendar’, :notice => “Successfully
updated launch.”

when you do this it things that notice is part of the routing options.
redirect_to({:action => ‘calendar’}, :notice => ‘…’) should work, as
should
redirect_to something_path, :notice => ‘…’

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs