I have the following resources
Places (:place_id, :name, :shortlink, :token)
Events (:event_id, :address)
I have a restricted user registration with a nested user resource (User has many Events).
When User register, (s)he create a new event with a referenced place column.
Users can only sign up when having theses parameters in the url
https://mysite/user/signup?q=[:place_id]&t=[:token] # place id must exist, place token must be equal to t parameter
before_action :check_has_access, only: [:new]
...
protected
def check_has_access
@place = Place.find(params[:q])
if params[:q].blank? && @place.blank? || params[:t].blank? || @place.token != params[:t]
redirect_to(root_path)
flash[:alert] = 'Restricted sign-up'
end
end
I want to generate a shortcut for each place for the user to register
https://mysite/[:shortlink] #place.shortlink
That will redirect to a given sign up form with corresponding filled form and restricted params so the user that has the direct url can sign up.
https://mysite/user/signup?q=[:place_id]&t=[:token]
How can I have routes to be generated ?
Subsidiary question, am I doing it right ?