I am trying to replicate the "demo/tutorial" at http://d-haven.org/modules/news/article.php?storyid=28 I have ran the generator and followed the instructions in the accompanying generator readme_login file. I have setup up a user database of the form create_table :users do |t| t.column :login, :string, :limit => 40 t.column :password, :string, :limit => 40 t.column :email, :string, :limit => 40 t.column :name, :string, :limit => 40 and from there followed the procedures listed at the site noted above thru the end of Step 2 including creating another table (articles table referred to in demo) with a user_id :interger column. After creating a user I attempt to create and save an article instance/record which fails at the validates_presence_of :user Can you see anything in the "demo/tutorial" code which is out of place or have I missed some step required to get the session :user properly assigned to the @article instance? Thanks, Bernie --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Cayce Balara
2006-Nov-12 04:09 UTC
Re: Trying to Replicate a Login Generator related Tutorial
Bernie wrote:> I am trying to replicate the "demo/tutorial" at > > http://d-haven.org/modules/news/article.php?storyid=28 > > I have ran the generator and followed the instructions in the > accompanying generator readme_login file. > > I have setup up a user database of the form > > create_table :users do |t| > t.column :login, :string, :limit => 40 > t.column :password, :string, :limit => 40 > t.column :email, :string, :limit => 40 > t.column :name, :string, :limit => 40 > > and from there followed the procedures listed at the site noted above > thru the end of Step 2 including creating another table (articles table > referred to in demo) with a user_id :interger column. > > After creating a user I attempt to create and save an article > instance/record which fails at the > > validates_presence_of :user > > Can you see anything in the "demo/tutorial" code which is out of place > or have I missed some step required to get the session :user properly > assigned to the @article instance? > > Thanks, > BernieDo you have a ''user'' field on your Articles table? I only skimmed the start of the post, but my first thought is that the articles table should have a ''user_id'' field, not a ''user'' field, to link Articles to Users through the has_many/belongs_to associations, and then the line should be: validates_presence_of :user_id c. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The field in the articles table is user_id. Also in the tutorial articles_controller there are references to @article.user and @session[:user]. Should these not be .user_id as well? (pardon my noobiness) On Nov 11, 10:09 pm, Cayce Balara <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Bernie wrote: > > I am trying to replicate the "demo/tutorial" at > > >http://d-haven.org/modules/news/article.php?storyid=28 > > > I have ran the generator and followed the instructions in the > > accompanying generator readme_login file. > > > I have setup up a user database of the form > > > create_table :users do |t| > > t.column :login, :string, :limit => 40 > > t.column :password, :string, :limit => 40 > > t.column :email, :string, :limit => 40 > > t.column :name, :string, :limit => 40 > > > and from there followed the procedures listed at the site noted above > > thru the end of Step 2 including creating another table (articles table > > referred to in demo) with a user_id :interger column. > > > After creating a user I attempt to create and save an article > > instance/record which fails at the > > > validates_presence_of :user > > > Can you see anything in the "demo/tutorial" code which is out of place > > or have I missed some step required to get the session :user properly > > assigned to the @article instance? > > > Thanks, > > BernieDo you have a ''user'' field on your Articles table? > > I only skimmed the start of the post, but my first thought is that the > articles table should have a ''user_id'' field, not a ''user'' field, to > link Articles to Users through the has_many/belongs_to associations, and > then the line should be: > > validates_presence_of :user_id > > c. > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I have a user_id field in the Articles table. On Nov 11, 10:09 pm, Cayce Balara <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Bernie wrote: > > I am trying to replicate the "demo/tutorial" at > > >http://d-haven.org/modules/news/article.php?storyid=28 > > > I have ran the generator and followed the instructions in the > > accompanying generator readme_login file. > > > I have setup up a user database of the form > > > create_table :users do |t| > > t.column :login, :string, :limit => 40 > > t.column :password, :string, :limit => 40 > > t.column :email, :string, :limit => 40 > > t.column :name, :string, :limit => 40 > > > and from there followed the procedures listed at the site noted above > > thru the end of Step 2 including creating another table (articles table > > referred to in demo) with a user_id :interger column. > > > After creating a user I attempt to create and save an article > > instance/record which fails at the > > > validates_presence_of :user > > > Can you see anything in the "demo/tutorial" code which is out of place > > or have I missed some step required to get the session :user properly > > assigned to the @article instance? > > > Thanks, > > BernieDo you have a ''user'' field on your Articles table? > > I only skimmed the start of the post, but my first thought is that the > articles table should have a ''user_id'' field, not a ''user'' field, to > link Articles to Users through the has_many/belongs_to associations, and > then the line should be: > > validates_presence_of :user_id > > c. > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Damaris Fuentes
2006-Nov-13 17:19 UTC
Re: Trying to Replicate a Login Generator related Tutorial
Bernie wrote:> I have a user_id field in the Articles table. > > On Nov 11, 10:09 pm, Cayce Balara <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Have a look to the session[:user] and so on, I think Login-generator puts the values with '''' (e.g. session[''user'']), and you articles or some other stuff may be asking for session[:user] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---