Need help with registration page

I have most of my books open as I’m trying to create this app. Still
not sure how to make this work - hopefully some help / hints can get
me further.

First I used the “authorizing users” recipe from Rails Recipes. Though
I did add some more generic type of registration fields (email,
address, etc).

I want the registration form on the main page(index) of the site.
What I have so far is
1- a main controller (with no methods in there , at least none of my
own)
2- a member controller (again no methods there)

3- a member model which contains the password stuff, hash and salt ,
so here is that code:
class Member < ActiveRecord::Base
def password=(pass)
salt = [Array.new(6){rand(256).chr}.join].pack(“m”).chomp
self.password_salt, self.password_hash =
salt, Digest::SHA256.hexdigest(pass + salt)
end
end

4- In the view in “main” I put in:
%= render :partial => “member/register” %>

5- so obviously I created the _register.rhtml partial.

The nice thing is domainname/main pulls up the page with the reg form.
Right now the controller doesn’t seem to be working correctly:

Here is the method:
def register
c = member.new(params[:member])
c.save
redirect_to :controller => “main”
end

I’m getting an error message
undefined local variable or method `member’ for
#MemberController:0x37bc690

Not sure what I"m doing wrong . Then again being a newb , not
entirely sure what I’m doing .

Stuart

3- a member model class Member < ActiveRecord::Base

Here is the method:
def register
c = member.new(params[:member])

I’m getting an error message
undefined local variable or method `member’ for
#MemberController:0x37bc690

I’m not 100% on this, but I think you might need to capitalize your
object
reference (e.g., Member.new()).

hth,
Bill

Yep, thank you , discovered that and it now works .

Stuart

the line
c = member.new(params[:member])

in your controller register action should be
c = Member.new(params[:member])

*M *uppercase

thats the only problem that I could see

-daya/fanoflinux

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