Project

General

Profile

about second development !help me

Added by tanggl tanggl about 14 years ago

!!recently,focus on second development of redmine,some question,as follow:
1、I want to save a object in registering together with object User,but it doesn't work,no any tips.
register_enterprise method of account_controller.rb :
#User of enterprise self-registration
def register_enterprise
redirect_to(home_url) && return unless Setting.self_registration? && Setting.enterprise_registration? || session[:auth_source_registration]
if request.get?
session[:auth_source_registration] = nil
user user = User.new(:language => Setting.default_language)
else
user user = User.new(params[:user])
@user.admin = true
@user.register

if session[:auth_source_registration]
@user.activate
@user.login = session[:auth_source_registration][:login]
@user.auth_source_id = session[:auth_source_registration][:auth_source_id]
if @user.save
session[:auth_source_registration] = nil
self.logged_user = @user
flash[:notice] = l(:notice_account_activated)
redirect_to :controller => 'my', :action => 'account'
end
else
@user.login = params[:user][:login]
@user.password, @user.password_confirmation = params[:password], params[:password_confirmation]
@enterpise = Enterprise.new(params[:enterprise])
@enterpise.introduction = params[:introduction]
@enterpise.register
case Setting.self_registration
when '1'
register_by_email_activation(@user)
when '3'
register_automatically(@user)
else
register_enterprise_manually_by_administrator(@user,@enterpise)
end
end
end
end
def register_enterprise_manually_by_administrator(user,enterprise, &block)
if enterprise.save and user.save # Sends an email to the administrators of enterprise
Mailer.deliver_account_activation_request(user)
account_pending
else
account_pending_failing
end
end
def account_pending_failing
flash[:notice] = l(:notice_account_pending)
redirect_to :action => 'register'
end
def account_pending
flash[:notice] = l(:notice_account_pending)
redirect_to :action => 'register'
end

Replies (1)

RE: about second development !help me - Added by Felix Schäfer about 14 years ago

I have a really really hard time reading that code, could you please include it in a < pre> block so that formatting is not lost (see the text formatting help for more info).

    (1-1/1)