Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def add
- user = User.new
- if request.post?
- begin
- if user.update_attributes(params[:user]) & user.save_with_validation
- flash[:info] = "User Created Successfully"
- else
- flash[:error] = "Can not add a user without selecting a group"
- raise
- end
- rescue
- flash[:error] ="There was an error createing the user"
- raise
- end
- end
- @user = user
- @groups = Group.find(:all)
- end
- <% form_for :user, @user, :url => { :action => "add" } do |user_form| %>
- First name: <%= user_form.text_field :first_name %>
- Last name : <%= user_form.text_field :last_name %>
- Email: <%= user_form.text_field :email %>
- Password: <%= user_form.password_field :password %>
- Confirm Password: <%= user_form.password_field :password_confirmation %>
- Groups:
- <% for group in @groups %>
- <%= group.name %> <%= check_box_tag('user[groups]', @groups, -1)%>
- <% end %>
- <%= submit_tag "Login" %>
- <% end %>
Add Comment
Please, Sign In to add comment