I''m new to Rails too, but I think I can give you some pointers. My app at the moment is similar, but instead of ''articles'' that belong to a ''user'' I have ''snippets'' that belong to a ''scrapbook''. So, my code to get the snippets for a scrapbook: controller: def index @user = @session[''user''] @scrapbook = @user.scrapbook end view: index.rhtml <p> <% for @snippet in @scrapbook.snippets.find_all %> <%= render_partial "listSnippets", @snippet %> <% end %> </p> _listSnippets partial: <p><a href="/snippet/show/<%= @snippet.id %>"><%= @snippet.title %></p> I hope that helps you a little. One thing you seem to be getting mixed up with is that a ''user'' doesn''t belong to an ''article'', but rather ''articles'' belong to a ''user''. So, to access your articles you use @user.articles.find_all . I think your model''s correct though. Cheers, Ben On Apr 5, 2005 1:37 PM, Michael Klein <michaelklein-fliffHUUhfJg9hUCZPvPmw@public.gmane.org> wrote:> I''ve recently developed a huge interest in Ruby on Rails and have read > several articles and many tutorials. > > Now I am attempting to write my own application. > > First off I am trying to make a simple post site. A very basic blog you > could say. I have installed the user system with "script/generate login > Account". I have the following two tables. > > CREATE TABLE articles( > id int(6) unsigned NOT NULL auto_increment, > content text NOT NULL, > title tinytext NOT NULL, > created_on timestamp NOT NULL default ''0000-00-00 00:00:00'', > updated_on timestamp NULL default NULL, > user_id int(4) NOT NULL default ''0'', > PRIMARY KEY (id) > ); > > CREATE TABLE users( > `id` int(11) NOT NULL auto_increment, > login varchar(80) default NULL, > `password` varchar(40) default NULL, > firstname varchar(80) default NULL, > lastname varchar(80) default NULL, > PRIMARY KEY (`id`) > ); > > I have created an Article controller which serves to show all of my > articles. > This is done through the show.rhtml: > > <% @article.each do |article| %> > <h3><%= article.title %></h2> > <p class="date">Written on <%= article.created_on.strftime "%e %B %Y @ > %I:%M %p" %></p> > <p class="article_content"><%= article.content %></p> > <p class="author">Written by <%= article.user %></p> > <% end %> > > The @article instance variable is declared in article_controller.rb > under "def show" as "@article = Article.find_all" The problem occurs > whenever I try and have it display the correct author, where it says > "Written by". I have tried <%= article.user.firstname %> rather than <%> article.user %> (which generates a "#" sign) and expected it to work, > but "firstname" gives a "NoMethodError". I realize this problem probably > comes from my two models. > > My article.rb model says "belongs_to :user" and my user.rb model says > "has_many :articles". I struggle to understand when to make things > plural or singular so I have tried :user/:articles, :users/:articles, > :users/:article, and :user/:article. None of these are working for me. > It seems as :articles/:user would make most sense. I thought the foreign > key "user_id" would help link these two, like its supposed to. > > Whenever I just say "<p class="author">Written by <%= article.user.id > %></p>" it actually puts out the id of the user that wrote the post. But > when "id" is changed to "firstname" or "login" or "lastname" it doesn''t > work. (This is using has_many :articles and belongs_to :user.) > > If someone can please point out my error I would appreciate it VERY > much! Thanks in advance! > > Michael > --- > [This E-mail scanned for viruses by Declude Virus] > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I''ve recently developed a huge interest in Ruby on Rails and have read several articles and many tutorials. Now I am attempting to write my own application. First off I am trying to make a simple post site. A very basic blog you could say. I have installed the user system with "script/generate login Account". I have the following two tables. CREATE TABLE articles( id int(6) unsigned NOT NULL auto_increment, content text NOT NULL, title tinytext NOT NULL, created_on timestamp NOT NULL default ''0000-00-00 00:00:00'', updated_on timestamp NULL default NULL, user_id int(4) NOT NULL default ''0'', PRIMARY KEY (id) ); CREATE TABLE users( `id` int(11) NOT NULL auto_increment, login varchar(80) default NULL, `password` varchar(40) default NULL, firstname varchar(80) default NULL, lastname varchar(80) default NULL, PRIMARY KEY (`id`) ); I have created an Article controller which serves to show all of my articles. This is done through the show.rhtml: <% @article.each do |article| %> <h3><%= article.title %></h2> <p class="date">Written on <%= article.created_on.strftime "%e %B %Y @ %I:%M %p" %></p> <p class="article_content"><%= article.content %></p> <p class="author">Written by <%= article.user %></p> <% end %> The @article instance variable is declared in article_controller.rb under "def show" as "@article = Article.find_all" The problem occurs whenever I try and have it display the correct author, where it says "Written by". I have tried <%= article.user.firstname %> rather than <%= article.user %> (which generates a "#" sign) and expected it to work, but "firstname" gives a "NoMethodError". I realize this problem probably comes from my two models. My article.rb model says "belongs_to :user" and my user.rb model says "has_many :articles". I struggle to understand when to make things plural or singular so I have tried :user/:articles, :users/:articles, :users/:article, and :user/:article. None of these are working for me. It seems as :articles/:user would make most sense. I thought the foreign key "user_id" would help link these two, like its supposed to. Whenever I just say "<p class="author">Written by <%= article.user.id %></p>" it actually puts out the id of the user that wrote the post. But when "id" is changed to "firstname" or "login" or "lastname" it doesn''t work. (This is using has_many :articles and belongs_to :user.) If someone can please point out my error I would appreciate it VERY much! Thanks in advance! Michael --- [This E-mail scanned for viruses by Declude Virus]
David Morton
2005-Apr-05 03:52 UTC
Re: Nuby Model Problems - All Help Sincerely Appreciated!
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Michael Klein wrote: | <% @article.each do |article| %> | <h3><%= article.title %></h2> | <p class="date">Written on <%= article.created_on.strftime "%e %B %Y @ | %I:%M %p" %></p> | <p class="article_content"><%= article.content %></p> | <p class="author">Written by <%= article.user %></p> | <% end %> | | The @article instance variable is declared in article_controller.rb | under "def show" as "@article = Article.find_all" The problem occurs | Whenever I just say "<p class="author">Written by <%= article.user.id | %></p>" it actually puts out the id of the user that wrote the post. But | when "id" is changed to "firstname" or "login" or "lastname" it doesn''t | work. (This is using has_many :articles and belongs_to :user.) | pluralization is actually quite simple... use it as it naturally sounds. find_all returns multiple articles, right? Then it should say: @articles = Article.find_all and then in the view: @articles.each do |article| I''m not sure what happens when you have a "@article" and a "article", but that sounds like a bad idea. You had it right in the model, belongs_to :user and has_many :articles Ok, but the real problem is article is an object that has the article info, but it doesn''t have the user info. To get at the user info, you need to call it like article.user.lastname - -- David Morton Maia Mailguard server side anti-spam/anti-virus solution: http://www.maiamailguard.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCUgt6SIxC85HZHLMRAmHcAJsFtcaLxWM9mjzqJQ6Xms102sK2ZwCffcYR LcFY2xdmyOXti5mpywYoRcY=WmFo -----END PGP SIGNATURE-----
Trevor Squires
2005-Apr-05 04:05 UTC
Re: Re: Nuby Model Problems - All Help Sincerely Appreciated!
shouldn''t it be @articles.each do |article| then you just do article.title or article.content etc... Trevor Michael Klein wrote:> Ok, so i''ve changed a few things. > Now my show.rhtml looks like this: > > <% @articles.each do |@articles| %> > <h3><%= @articles.title %></h2> > <p class="date">Written on <%= @articles.created_on.strftime "%e %B %Y @ > %I:%M > %p" %></p> > <p class="article_content"><%= @articles.content %></p> > <p class="author">Written by <%= @articles.user.firstname %></p> > <% end %> > > But this is still generating an error. firstname is an unidentified method, > still. I didn''t change my user.rb model says "has_many :articles" and my > article.rb "belongs_to :user". I didn''t change my article_controller.rb > from > saying: "@articles = Article.find_all". > > I am seriously confused about what is wrong. Thanks for the help from > David and > Ben, please followup if you can! > > > pluralization is actually quite simple... use it as it naturally sounds. > > find_all returns multiple articles, right? Then it should say: > > <at> articles = Article.find_all > > > > and then in the view: <at> articles.each do |article| > > > > I''m not sure what happens when you have a " <at> article" and a > "article", > > but that sounds like a bad idea. > > > > You had it right in the model, belongs_to :user and has_many :articles > > > > Ok, but the real problem is article is an object that has the article > > info, but it doesn''t have the user info. To get at the user info, you > > need to call it like article.user.lastname > > > > -- > > David Morton > > Maia Mailguard server side anti-spam/anti-virus solution: > > http://www.maiamailguard.com > > > --- > [This E-mail scanned for viruses by Declude Virus] > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Rob Park
2005-Apr-05 04:21 UTC
Re: Re: Nuby Model Problems - All Help Sincerely Appreciated!
On Apr 4, 2005 10:56 PM, Michael Klein <michaelklein-fliffHUUhfJg9hUCZPvPmw@public.gmane.org> wrote:> Now my show.rhtml looks like this: > > <% @articles.each do |@articles| %>Um, no... you''ve misunderstood something somewhere. First, the "show" action by default is meant to just show one article, not list them all (this is what the "list" action is for). If you''ve changed that, that''s fine (like I said, these are just defaults, not anything that is enforced by rails), but you might be getting a bit confused about it and it''s messing you up. Dunno. Secondly, "@articles.each do |@articles|" doesn''t mean anything... you can''t have the same variable as your iterator as the collection you''re iterating over. This should surely be "@articles.each do |article|"> <h3><%= @articles.title %></h2>article.title> <p class="date">Written on <%= @articles.created_on.strftime "%e %B %Y @article.created.on...> <p class="article_content"><%= @articles.content %></p>article.content> <p class="author">Written by <%= @articles.user.firstname %></p>This one should work fine as article.user.firstname. The only thing i can think of is, is the "firstname" field set to null in your db? In my rails project I have articles that "belongs_to :category" and categories that "has_many :articles". I don''t actually use this, but I just tested it, just for you, and "@article.category.name" worked fine for me ("name" being a field in the category table). Keep in mind though, this is in my "show" action, where there is only one @article object, I''m not iterating over the list of them. So in your show action where you''re iterating over all of them, it''d have to be "article.user.firstname".> But this is still generating an error. firstname is an unidentified method, > still. I didn''t change my user.rb model says "has_many :articles" and my > article.rb "belongs_to :user". I didn''t change my article_controller.rb from > saying: "@articles = Article.find_all".Well, I think it would help a lot if you simply attached your article_controller.rb, article.rb and user.rb files in their entirety so that we can see exactly what is happening instead of trying to go by what you''re saying. At least that would help me figure out what''s wrong. -- Urban Artography http://artography.ath.cx
Michael Klein
2005-Apr-05 04:56 UTC
Re: Nuby Model Problems - All Help Sincerely Appreciated!
Ok, so i''ve changed a few things. Now my show.rhtml looks like this: <% @articles.each do |@articles| %> <h3><%= @articles.title %></h2> <p class="date">Written on <%= @articles.created_on.strftime "%e %B %Y @ %I:%M %p" %></p> <p class="article_content"><%= @articles.content %></p> <p class="author">Written by <%= @articles.user.firstname %></p> <% end %> But this is still generating an error. firstname is an unidentified method, still. I didn''t change my user.rb model says "has_many :articles" and my article.rb "belongs_to :user". I didn''t change my article_controller.rb from saying: "@articles = Article.find_all". I am seriously confused about what is wrong. Thanks for the help from David and Ben, please followup if you can! > pluralization is actually quite simple... use it as it naturally sounds. > find_all returns multiple articles, right? Then it should say: > <at> articles = Article.find_all > > and then in the view: <at> articles.each do |article| > > I''m not sure what happens when you have a " <at> article" and a "article", > but that sounds like a bad idea. > > You had it right in the model, belongs_to :user and has_many :articles > > Ok, but the real problem is article is an object that has the article > info, but it doesn''t have the user info. To get at the user info, you > need to call it like article.user.lastname > > -- > David Morton > Maia Mailguard server side anti-spam/anti-virus solution: > http://www.maiamailguard.com > --- [This E-mail scanned for viruses by Declude Virus]
Michael Klein
2005-Apr-05 12:58 UTC
Re: Nuby Model Problems - All Help Sincerely Appreciated!
More changes, as recommended:>First, the "show" >action by default is meant to just show one article, not list them all >(this is what the "list" action is for). If you''ve changed that, >that''s fine (like I said, these are just defaults, not anything that >is enforced by rails), but you might be getting a bit confused about >it and it''s messing you up. Dunno.I''ve changed my action from "show" to "list", like you said - it makes a lot more sense>Secondly, " <at> articles.each do | <at> articles|" doesn''t meananything... you>can''t have the same variable as your iterator as the collection you''re >iterating over. This should surely be " <at> articles.each do |article|"The new list.rhtml is : <% @articles.each do |article| %> <h3><%= article.title %></h2> <p class="date">Written on <%= article.created_on.strftime "%e %B %Y @ %I:%M %p" %></p> <p class="article_content"><%= article.content %></p> <p class="author">Written by <%= article.user.firstname %></p> <% end %> Once again articles.user.firstname generates a "NoMethodError".>This one should work fine as article.user.firstname. The only thing I >can think of is, is the "firstname" field set to null in your db?I can assure you that I do have experience with MySQL and this isn''t set to null.>Well, I think it would help a lot if you simply attached your >article_controller.rb, article.rb and user.rb files in their entirety >so that we can see exactly what is happening instead of trying to go >by what you''re saying. At least that would help me figure out what''s >wrong.The links to the files requested are: article_controller.rb - http://swilly.tk/~klein/ruby/article_controller.rb article.rb - http://swilly.tk/~klein/ruby/article.rb user.rb - http://swilly.tk/~klein/ruby/user.rb list.rhtml - http://swilly.tk/~klein/ruby/list.rhtml I have decided to just go ahead and zip the entire app, the entire 10 lines of code that I''ve actually made myself. http://swilly.tk/~klein/ruby/modelhelpapp.zip Thank you all so much for your help - especially Rob. --- [This E-mail scanned for viruses by Declude Virus]
Ben Myles
2005-Apr-05 16:34 UTC
Re: Re: Nuby Model Problems - All Help Sincerely Appreciated!
Very basic suggestion - you probably already thought of it - but are you using fastcgi at all? If you made changes to your controller or model, you need to restart your web server to make them current, or at least that''s what I found I needed to do. Perhaps there''s a better way than restarting, but I just run my own lighttpd daemon so restarting is easy enough for me. Ben On Apr 5, 2005 10:58 PM, Michael Klein <michaelklein-fliffHUUhfJg9hUCZPvPmw@public.gmane.org> wrote:> More changes, as recommended: > > >First, the "show" > >action by default is meant to just show one article, not list them all > >(this is what the "list" action is for). If you''ve changed that, > >that''s fine (like I said, these are just defaults, not anything that > >is enforced by rails), but you might be getting a bit confused about > >it and it''s messing you up. Dunno. > > I''ve changed my action from "show" to "list", like you said - it makes a > lot more sense > > >Secondly, " <at> articles.each do | <at> articles|" doesn''t mean > anything... you > >can''t have the same variable as your iterator as the collection you''re > >iterating over. This should surely be " <at> articles.each do |article|" > > The new list.rhtml is : > > <% @articles.each do |article| %> > <h3><%= article.title %></h2> > <p class="date">Written on <%= article.created_on.strftime "%e %B %Y @ > %I:%M %p" %></p> > <p class="article_content"><%= article.content %></p> > <p class="author">Written by <%= article.user.firstname %></p> > <% end %> > > Once again articles.user.firstname generates a "NoMethodError". > > >This one should work fine as article.user.firstname. The only thing I > >can think of is, is the "firstname" field set to null in your db? > > I can assure you that I do have experience with MySQL and this isn''t set > to null. > > >Well, I think it would help a lot if you simply attached your > >article_controller.rb, article.rb and user.rb files in their entirety > >so that we can see exactly what is happening instead of trying to go > >by what you''re saying. At least that would help me figure out what''s > >wrong. > > The links to the files requested are: > > article_controller.rb - http://swilly.tk/~klein/ruby/article_controller.rb > article.rb - http://swilly.tk/~klein/ruby/article.rb > user.rb - http://swilly.tk/~klein/ruby/user.rb > list.rhtml - http://swilly.tk/~klein/ruby/list.rhtml > > I have decided to just go ahead and zip the entire app, the entire 10 > lines of code that I''ve actually made myself. > > http://swilly.tk/~klein/ruby/modelhelpapp.zip > > Thank you all so much for your help - especially Rob. > > --- > [This E-mail scanned for viruses by Declude Virus] > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Jarkko Laine
2005-Apr-05 16:40 UTC
Re: Re: Nuby Model Problems - All Help Sincerely Appreciated!
On 5.4.2005, at 19:34, Ben Myles wrote:> Very basic suggestion - you probably already thought of it - but are > you using fastcgi at all? > > If you made changes to your controller or model, you need to restart > your web server to make them current, or at least that''s what I found > I needed to do. Perhaps there''s a better way than restarting, but I > just run my own lighttpd daemon so restarting is easy enough for me.This is only true if you''re running in production mode. In development mode they are loaded for every request. You can set the environment in your lighttpd config file: fastcgi.server = ( ".fcgi" => ( "localhost" => ( "min-procs" => 1, "max-procs" => 5, "socket" => "/tmp/diary.fcgi.socket", "bin-path" => "/Users/jarkko/Sites/diary/public/dispatch.fcgi", "bin-environment" => ( "RAILS_ENV" => "development" ) ) ) ) Alternatively, you can also set it in your config/environment.rb file. //jarkko> > Ben > > On Apr 5, 2005 10:58 PM, Michael Klein <michaelklein-fliffHUUhfJg9hUCZPvPmw@public.gmane.org> > wrote: >> More changes, as recommended: >> >>> First, the "show" >>> action by default is meant to just show one article, not list them >>> all >>> (this is what the "list" action is for). If you''ve changed that, >>> that''s fine (like I said, these are just defaults, not anything that >>> is enforced by rails), but you might be getting a bit confused about >>> it and it''s messing you up. Dunno. >> >> I''ve changed my action from "show" to "list", like you said - it >> makes a >> lot more sense >> >>> Secondly, " <at> articles.each do | <at> articles|" doesn''t mean >> anything... you >>> can''t have the same variable as your iterator as the collection >>> you''re >>> iterating over. This should surely be " <at> articles.each do >>> |article|" >> >> The new list.rhtml is : >> >> <% @articles.each do |article| %> >> <h3><%= article.title %></h2> >> <p class="date">Written on <%= article.created_on.strftime "%e %B %Y @ >> %I:%M %p" %></p> >> <p class="article_content"><%= article.content %></p> >> <p class="author">Written by <%= article.user.firstname %></p> >> <% end %> >> >> Once again articles.user.firstname generates a "NoMethodError". >> >>> This one should work fine as article.user.firstname. The only thing I >>> can think of is, is the "firstname" field set to null in your db? >> >> I can assure you that I do have experience with MySQL and this isn''t >> set >> to null. >> >>> Well, I think it would help a lot if you simply attached your >>> article_controller.rb, article.rb and user.rb files in their entirety >>> so that we can see exactly what is happening instead of trying to go >>> by what you''re saying. At least that would help me figure out what''s >>> wrong. >> >> The links to the files requested are: >> >> article_controller.rb - >> http://swilly.tk/~klein/ruby/article_controller.rb >> article.rb - http://swilly.tk/~klein/ruby/article.rb >> user.rb - http://swilly.tk/~klein/ruby/user.rb >> list.rhtml - http://swilly.tk/~klein/ruby/list.rhtml >> >> I have decided to just go ahead and zip the entire app, the entire 10 >> lines of code that I''ve actually made myself. >> >> http://swilly.tk/~klein/ruby/modelhelpapp.zip >> >> Thank you all so much for your help - especially Rob. >> >> --- >> [This E-mail scanned for viruses by Declude Virus] >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Ben Myles
2005-Apr-05 16:54 UTC
Re: Re: Nuby Model Problems - All Help Sincerely Appreciated!
Thanks a million! That will make life a lot easier. I think I might start compiling an FAQ page from the useful advice on this list. Ben On Apr 6, 2005 2:40 AM, Jarkko Laine <jarkko-k1O+Gnc6WpmsTnJN9+BGXg@public.gmane.org> wrote:> This is only true if you''re running in production mode. In development > mode they are loaded for every request. You can set the environment in > your lighttpd config file: > > fastcgi.server = ( ".fcgi" => > ( "localhost" => > ( > "min-procs" => 1, > "max-procs" => 5, > "socket" => "/tmp/diary.fcgi.socket", > "bin-path" => "/Users/jarkko/Sites/diary/public/dispatch.fcgi", > "bin-environment" => ( "RAILS_ENV" => "development" ) > ) > ) > ) > > Alternatively, you can also set it in your config/environment.rb file. > > //jarkko
Michael Klein
2005-Apr-05 18:03 UTC
Re: Nuby Model Problems - All Help Sincerely Appreciated!
Ben Myles <ben.myles@...> writes:> > Very basic suggestion - you probably already thought of it - but are > you using fastcgi at all? > > If you made changes to your controller or model, you need to restart > your web server to make them current, or at least that''s what I found > I needed to do. Perhaps there''s a better way than restarting, but I > just run my own lighttpd daemon so restarting is easy enough for me. > > BenI''m just using the included script/server - WEBrick 1.3.1. I don''t think it needs resarting, but I went ahead and did so but my artilce.user.firstname still doesn''t work..
Michael Klein
2005-Apr-05 19:34 UTC
Re: Re: Re: Nuby Model Problems - All Help Sincerely Appreciated!
Rob, I think "desperate" would accurately describe me and my rails app situation now. Sounds like a good idea, its probably just some typo or something that I can''t find. I think this time I might try to fool around with "has_and_belongs_to_many" with my database. Thanks for all your help, its really been great. Consider this case "solved." Michael Rob Park <rbpark@...> writes: > > On Apr 5, 2005 12:03 PM, Michael Klein <michaelklein@...> wrote: > > I''m just using the included script/server - WEBrick 1.3.1. I don''t think it > > needs resarting, but I went ahead and did so but my artilce.user.firstname still > > doesn''t work.. > > yeah, webrick should be fine. That''s bizarre though... your code looks > fine to me, I''m not sure why it''s not working. Pretty much that exact > code works fine in my rails project. > > If I was in your situation, and I was getting desperate, what I''d try > doing is to just start a whole new rails project (make sure you have > the latest version of ruby, and rails), and then instead of writing > "scaffold :articles", I''d actually generate the scaffold code > outright, so that you can see it and poke around with it. > > So make a new rails project, copy over your old database.yml file, and > then instead of doing "ruby script/generate model Articles", just do > "ruby script/generate scaffold Article", and have a look at the code > it produces. Then add in your "belongs_to" and "has_many", and see if > you can get it working from there. > --- [This E-mail scanned for viruses by Declude Virus]
Rob Park
2005-Apr-05 20:23 UTC
Re: Re: Nuby Model Problems - All Help Sincerely Appreciated!
On Apr 5, 2005 12:03 PM, Michael Klein <michaelklein-fliffHUUhfJg9hUCZPvPmw@public.gmane.org> wrote:> I''m just using the included script/server - WEBrick 1.3.1. I don''t think it > needs resarting, but I went ahead and did so but my artilce.user.firstname still > doesn''t work..yeah, webrick should be fine. That''s bizarre though... your code looks fine to me, I''m not sure why it''s not working. Pretty much that exact code works fine in my rails project. If I was in your situation, and I was getting desperate, what I''d try doing is to just start a whole new rails project (make sure you have the latest version of ruby, and rails), and then instead of writing "scaffold :articles", I''d actually generate the scaffold code outright, so that you can see it and poke around with it. So make a new rails project, copy over your old database.yml file, and then instead of doing "ruby script/generate model Articles", just do "ruby script/generate scaffold Article", and have a look at the code it produces. Then add in your "belongs_to" and "has_many", and see if you can get it working from there. -- Urban Artography http://artography.ath.cx