Guest User

Untitled

a guest
Mar 9th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. def add
  2. user = User.new
  3. if request.post?
  4. begin
  5. if user.update_attributes(params[:user]) & user.save_with_validation
  6. flash[:info] = "User Created Successfully"
  7. else
  8. flash[:error] = "Can not add a user without selecting a group"
  9. raise
  10. end
  11. rescue
  12. flash[:error] ="There was an error createing the user"
  13. raise
  14. end
  15. end
  16. @user = user
  17. @groups = Group.find(:all)
  18. end
  19.  
  20. <% form_for :user, @user, :url => { :action => "add" } do |user_form| %>
  21. First name: <%= user_form.text_field :first_name %>
  22. Last name : <%= user_form.text_field :last_name %>
  23. Email: <%= user_form.text_field :email %>
  24. Password: <%= user_form.password_field :password %>
  25. Confirm Password: <%= user_form.password_field :password_confirmation %>
  26. Groups:
  27. <% for group in @groups %>
  28. <%= group.name %> <%= check_box_tag('user[groups]', @groups, -1)%>
  29. <% end %>
  30. <%= submit_tag "Login" %>
  31. <% end %>
Add Comment
Please, Sign In to add comment