Authlogic

Hi
I am using authlogic version 2.1.3. I have two models companies and
users.

company has_many users
user belongs_to company

 Upon registration one company and a user is created at the same

time. And the flow is after registration not goes directly to
application but redirect to login page…And I am saying

accepts_nested_attributes_for :users in company model So in companies
create action I say just
@company = Company.new(params[:company])
@company.save

  All these are ok . But my problem is after save I think a

session is started there Dont know why? (If a manually clear browser
cache everything ok) And so that I tried to use

@company.save_without_session_maintenance

Surely this is not correct. But please guide how can I do this?

Thanks
Tom

Hi
I could not solve the problem yet.Please help

Thanks
Tom

Hi
I partially succeeded in this .But there is also a problem What
I did is just add a :active boolean column to users table . Now I can
save company ( so user also) without session maintenece. But my
requirement is after this just redirect to login page and from there
login to pplication by giving email and password which was saved in
last step. But since :active column is false cant login

 My question is whether in the same scenario can I save company

model(with user) and by any means by adding some obserever in the user
model and say “Please save without session maintanace”. This was my
first question

Thanks
Tom

On Fri, 2010-01-29 at 10:44 +0100, Tom M. wrote:

model and say “Please save without session maintanace”. This was my
first question


1 - there is a mail list for authlogic

2 - you can set the column ‘active’ to be true in the controller code
before you save…

@user = params[:user]
@user.active = true
@user.save_without_session_maintenance!

3 - you probably want to show actual code for better answers

Craig


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Hi

Thanks for your reply. My model code is

class User < ActiveRecord::Base
acts_as_authentic
belongs_to :company
end

class Company < ActiveRecord::Base
has_many :users
accepts_nested_attributes_for :users
end

My companies controller is
def new
@company = Company.new
1.times { @company.users.build }
end

def create
  @company = Company.new(params[:company])
  if @company.valid_with_captcha? and @company.save
        flash[:notice] = "Thanks for registering. Please login"
        redirect_to login_url
  else
    render :action => :new
  end
end

  So here I have no control over save_without_session_maintenance 

(Or I dont know how to do it) The problem is after this save (one
company and a user)
it is not redireted to login_url . I think some cookie is set. Can I
save company and user from the above code?

Thanks
Tom

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs