Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- View:
- <% form_for(:user, :url => domain_users_path) do |f| %>
- <fieldset>
- <label class="field-username">new email *<input type="text" name="username" value="" /></label><span class="secondary_label">@<%=h @domain.domain %></span>
- <label class="field-password">password *<input type="password" name="password" value="" /></label>
- <label class="field-name">full name *<input type="text" name="first_name" value="" /></label>
- <%= submit_tag "Create" %>
- </fieldset>
- <% end %>
- controller:
- def create
- @user = User.new(params[:user])
- @domain = Domain.find params[:domain_id]
- respond_to do |format|
- if @user.save
- flash[:notice] = 'User was successfully created.'
- format.html { redirect_to domain_url(@domain.id) }
- else
- format.html { render :action => "new" }
- end
- end
- end
- model:
- class User < ActiveRecord::Base
- belongs_to :domain
- def before_save
- self.homedir = "/home/vmail"
- self.quota = "0"
- self.maildir = "/home/vmail/#{@domain.id}/#{:username}/.maildir/"
- :full_email
- end
- attr_accessor :username
- def password=(p)
- self.clear = p
- end
- def password
- clear
- end
- def full_email=(username)
- self.email = "#{username}@#{@domain.id}"
- end
- def full_email
- email
- end
- end
Add Comment
Please, Sign In to add comment