Hey!
I have users registration procedure on my app. But my users have to register with promo code. So I have model Promocodes for that:
t.references :user #this is who have create that promo, e.g. Admin
t.string :name #a "name" for promo, e.g. "some_promo"
t.integer :allowreg #how much registrations can be done using that promo key
So now, when registering, I have to check promo. But how it can be done?! Here is my view for signup form:
<% form_for @user do |f| %>
<%= f.error_messages %>
<fieldset>
<ol>
<li>
<%= f.label "Promo key" %>
??????????????????????????????????
There have to be a field for promo key
???????????????????????????????????
</li>
<li>
<%= f.label :login, 'Login' %>
<%= f.text_field :login %>
</li>
<li>
<%= f.label :email %>
<%= f.text_field :email %>
</li>
<li>
<%= f.label :password, "Pass" %>
<%= f.password_field :password %>
</li>
<li>
<%= f.label :password_confirmation, 'Pass again' %>
<%= f.password_field :password_confirmation %>
</li>
</ol>
</fieldset>
<div class="buttons">
<%= submit_tag 'Signup!' %>
</div>
<% end %>
Thank you!