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" %></td> 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
the line c = member.new(params[:member]) in your controller register action should be c = *M*ember.new(params[:member]) *M *uppercase thats the only problem that I could see -daya/fanoflinux On 8/2/06, Dark Ambient <sambient@gmail.com> wrote:> > 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" %></td> > > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060802/648f01cd/attachment.html
> 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 On 8/2/06, Bill Walton <bill.walton@charter.net> wrote:> > 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 > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >