Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This gist explains how to use render or redirect_to for HTTP response

render and redirect_to

To

redirect_to

redirect_to '/', alert: 'this works'

flash.alert = 'works too'
redirect_to '/'

render

to pass parameter, do

render 'new', usecase: 'register'

Then in new.html.erb, you can access params[:usecase] and get 'register'

To flash with render

flash.alert = '...' ; render 'form'

render 'form', alert: 'Not working'

In erb, you can

<p style='color: red'><%=flash.alert %><p>
<p style='color: green'><%=alert %><p> # works too
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment