Im trying to pass a variable from controller to my form to no avail.
Its working in another controller but cannot make it work for new user registrations.
def update
@profile = Profile.find(params[:id])
@profile.form = "signup"
...
end
Inside model I can do @profile.form to get the value
This does not work for new user registrations: inside create action:
undefined method `form=' for nil:NilClass
how to pass a variable to my model upon new user registration? User = User.new then @user.form == "signup" does not work either, i have :form in my attributes accessible list
Part of model:
attr_accessible form
...
validates :city_id, :presence => true, :if => :signup?
def signup?
#@profile.form == "signup"
#@user.form == "signup"
if self.form == "signup"
return true
else
return false
end
end
EDIT 1: Still unable to pass a param to the model :S:S:S tried every possible way and google found solution.
The create method for my registrations#create =
def create
profile = Profile.new
profile.form = "signup"
super
end