I want to pass 2 strings to the view after redirecting.
the controller:
def create
@rating = Rating.new(params[:rating])
respond_to do |format|
if @rating.save
format.html { redirect_to @rating, :notice => 'Got It!' ,
:notice_small => 'Your photo has been uploaded. good luck with it\'s coolness rating!' }
format.json { render :json => @rating, :status => :created, :location => @rating }
else
format.html { render :action => "new" }
format.json { render :json => @rating.errors, :status => :unprocessable_entity }
end
end
end
the view:
<p id="notice" class="big_notice"><%= notice %></p>
<% if defined? notice_small %>
<p id="small_notice" class="small_notice"><%= notice_small %></p>
<% end %>
the notice string goes throw but the notice_small does not, why?
Only
:noticeand:alertare allowed to be set usingredirect_to.If you want something beyond this, use
:flash => { :notice_small => '....' }option forredirect_toor setflash[:notice_small]beforeredirect_toexplicitly.