# Authlogic

**URL:** <https://www.ruby-forum.com/t/authlogic/182372>\
**Category:** Rails\
**Created:** [January 27, 2010, 5:15am UTC](https://www.ruby-forum.com/t/authlogic/182372 "2010-01-27T05:15:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [January 27, 2010, 5:15am UTC](https://www.ruby-forum.com/t/authlogic/182372/1 "2010-01-27T05:15:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [January 28, 2010, 10:14am UTC](https://www.ruby-forum.com/t/authlogic/182372/2 "2010-01-28T10:14:13Z")

</div>

Hi  
I could not solve the problem yet.Please help

Thanks  
Tom

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [January 29, 2010, 10:44am UTC](https://www.ruby-forum.com/t/authlogic/182372/3 "2010-01-29T10:44:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [January 29, 2010, 5:44pm UTC](https://www.ruby-forum.com/t/authlogic/182372/4 "2010-01-29T17:44:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [January 30, 2010, 4:48am UTC](https://www.ruby-forum.com/t/authlogic/182372/5 "2010-01-30T04:48:09Z")

</div>

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
