On Jul 21, 9:13 pm, "Leonel *.*" <li...@ruby-forum.com> wrote: > Sorry, I should've explained more. This is the general idea. > > There is a Sign Up form which creates 3 records in 3 different models: > Account > Company (belongs to account) > User (belongs to user) > > So the Sign Up form, creates the user from the accounts_controller.rb > @account = Account.new > company = @account.companies.build > company.users.build > > Now, once the sign up is complete, the user can invite other people to > user the web app. So he adds users, the app sends an invitation email > and when the person clicks on the invitation email, it gives it a form > to choose desired username. > > In summary... > 1) when the user is being created from the accounts controller (sign > up), REQUIRE username > 2) when the user is adding other users from users controller (add user), > DO NOT REQUIRE username >
I don't think you want to think of this as a controller based thing. Apart from anything else, if you at some later point want to update a user object then you'll need to know what validations to apply. Instead, you could have a state column, and apply validations based on that state. When the accounts controller creates a user, it sets its state to (for example) signed_up, and that state requires all your validation, whereas in the second case the controller could set the state to 'invited', which has a separate set of validations. (if you do go down this route, the aasm gem can help you manage states and the transitions between them) Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.