0

How can you prepopulate a Reform form object with variables from the query string?

I understand how to call prepopulate! but how do I access a variable on the URL from within the Reform contract?

For example:

/example/new?lang=en

property :language, virtual: true, prepopulator: ->(*) { ??? }
4

1 回答 1

0

To follow the docs on Trailblazer GitHub:

class AlbumsController
  def new
    @form = AlbumForm.new(Album.new)
  end

should be:

class AlbumsController
  def new
    @form = AlbumForm.new(Album.new(language: params[:lang]))
  end
于 2017-03-20T17:56:10.210 回答