Pepeng Agimat
Pepeng Agimat

Reputation: 167

How I can pass a value in format.html with redirect_to in rails

I tried to pass uuid and msg in the format.html { redirect_to @sample, notice: { uuid: @sample.uuid, msg: @sample.msg } to display in the view but I think it's not the proper way of passing a value.

And when I want to access in the view

<%= flash[:notice][:code] %> <%= flash[:notice][:id] %>

doesn't display the flash..

Upvotes: 1

Views: 407

Answers (1)

Zoran
Zoran

Reputation: 4226

To be able to access those values via flash, try the following:

format.html { redirect_to @sample, flash: { uuid: @sample.uuid, msg: @sample.msg } }

You can then access them via <%= flash[:uuid] %> or <%= flash[:msg] %>

Hope it helps!

Upvotes: 3

Related Questions