Rails
Setting the content location
On non-GET visits, Breezy uses the response's content-location to create the key used to store your props.
This is because when you render in a create or update, the returned response does not necessarily reflect the url the user should see.
For example, when the user is on posts/new and they make a POST request to posts/, we may decide to render posts/new for any errors you'd like to show.
It is recommended that you set this header in your create and update methods. If you used the generators, this is done for you.
def create
@post = Post.new(post_params)
if @post.save
redirect_to @post, notice: 'Post was successfully created.'
else
response.set_header("content-location", new_post_path)
render :new
end
endRails Flash
Your Rails flash will work as expected. On the React side, you receive the flash in the props of your connected component:
class PostsIndex extends React.Component {
render () {
const {
flash,
} = this.props
...
}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(PostsIndex)redirect_back_with_bzq
redirect_back_with_bzqA helper to help retain the bzq parameter as part of the redirect location. This helper has the same method signature as Rails own redirect_back.
def create
redirect_back_with_bzq fallback_url: '/'
endprops_from_form_with
A view helper that will give you the camelized attributes generated by form_with that can be used to passed to React. Has the same method signature as form_with
json.form_props props_from_form_with(
url: venue_floor_seats_path(venue, floor),
method: :get,
)Last updated
Was this helpful?