Hussam Ali wrote in post #1019017:
> Im trying to redirect the user after the sign up by saving the referer
> in case when user came to sign up through clicking on any specific page.
> But its not working properly.
>
> I'm using Devise, and i have 2 step registration, after sign up user
> redirects to profile completion and it is mandatory and after that im
> redirecting to referer. Please tell me what is the problem ?
>
> In my application controller,
>
> before_filter : save_referer
>
> def save_referer
>   unless user_signed_in?
>     unless session['referer']
>       session['referer'] = request.referer || 'none'
>     end
>   end
> end
>
> In User Model,
>
> def save_with(referer)
>   referer = referer unless referer == "null"
>   self.save
> end
>

Of course, referer = referer doesn't do anything.  Suppose you did this:

x = 2
x= x

What do you think x is equal to now?  Does the second line do anything?

>
> Initally i did self.referer
>

Your initial instincts were good.


> but then i got undefined method `referer='
> for #<User:0xc4a8bf0>
>

In ruby, if you write:

any_object.attribute = some_val

That is equivalent to:

any_object.attribute=(some_val)

In other words, you are calling a method named 'attribute='.  So that 
method has to be defined somewhere.

When you use rails to create your Model, for every column you specify 
rails will create attributes for your model object, and also call 
attr_accessor() for each attribute.  If you don't know what 
attr_accessor() does, look it up.

If you don't specify an attribute when you initially create your model, 
you can add an attribute to your model with a migration, which will also 
create the accessor methods.  Or, if the attribute is a virtual 
attribute, i.e. not saved in the db, then you have to manually call 
attr_accessor in your model.

-- 
Posted via http://www.ruby-forum.com/.