Hi folks. I''m just starting to learn ruby and rails, and I''m working through a tutorial. I''ve hit a hurdle attempting to add a column to a table. I''ve created the migration file and ran it through rake, and I can see that the db (mysql) has changed. However, from what I''ve read, this new column should immediately be reflected in the app; in other words, when I create a new widget in the app, a new form field should appear on the page. But, this isn''t happening. Can anybody explain why? Thanks! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 16 March 2010 14:35, Jeff Ramin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> However, from what I''ve read, this new column should immediately be > reflected in the app; in other words, when I create a new widget in the > app, a new form field should appear on the page. But, this isn''t > happening.Being "reflected in the app" and appearing on the page are two different things. The field *is* available as a method on the model, but it''s not going to appear on any page (other than a list that is iterating through all the model''s columns) unless you put it there. It would be highly annoying if every time you added a field it appeared randomly on views :-) You need to edit the view file (the erb, or rhtml if it''s an older version of Rails) and put the HTML to display the field you''ve created wherever you want it to appear. if you want to be *sure*, you can add <%= @model.my_new_field %> anywhere in the view, and edit a record in the DB - refresh to see your DB-edited value. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling wrote:> On 16 March 2010 14:35, Jeff Ramin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> However, from what I''ve read, this new column should immediately be >> reflected in the app; in other words, when I create a new widget in the >> app, a new form field should appear on the page. But, this isn''t >> happening. > > Being "reflected in the app" and appearing on the page are two different > things. > > The field *is* available as a method on the model, but it''s not going > to appear on any page (other than a list that is iterating through all > the model''s columns) unless you put it there. It would be highly > annoying if every time you added a field it appeared randomly on views > :-) > > You need to edit the view file (the erb, or rhtml if it''s an older > version of Rails) and put the HTML to display the field you''ve created > wherever you want it to appear. > > if you want to be *sure*, you can add <%= @model.my_new_field %> > anywhere in the view, and edit a record in the DB - refresh to see > your DB-edited value.Thanks. According to "Agile Web Development with Rails", the field should automagically appear on views, but that was using rails 1.2 and using scaffold in the controller. I''m running rails 2.3.x, so wasn''t able to use "scaffold" in the way described in the book. Does that explain the (mis)behavior? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 16 March 2010 14:55, Jeff Ramin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> According to "Agile Web Development with Rails", the field should > automagically appear on views, but that was using rails 1.2 and using > scaffold in the controller. I''m running rails 2.3.x, so wasn''t able to > use "scaffold" in the way described in the book. > > Does that explain the (mis)behavior?Which version of the book have you got?! If it''s v2 or earlier, lots of it is going to be wrong for the version you have installed, which is going to be very frustrating at times. But yes - the scaffolding used to loop through all the columns : <% for column in License.content_columns %> <p> <b><%= column.human_name %>:</b> <%=h @license.send(column.name) %> </p> <% end %> ...but that''s intensely annoying because you have to *totally* remove it to replace it with anything useful. Now, the individual fields get rendered one after an other - so you can tweak the scaffolded file, rather than re-write it completely. (of course the down side is if you add a new field to the db, you have to add it to the view) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Mar 16, 2010 at 7:55 AM, Jeff Ramin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> According to "Agile Web Development with Rails", the field should > automagically appear on views, but that was using rails 1.2 and using > scaffold in the controller. I''m running rails 2.3.x, so wasn''t able to > use "scaffold" in the way described in the book.You''re setting yourself up for continuous pain and frustration by using an out-of-date reference with a current Rails version. Toss that book and get the latest, or use online tutorials based on the 2.3.x branch. Really. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling wrote:> On 16 March 2010 14:55, Jeff Ramin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> According to "Agile Web Development with Rails", the field should >> automagically appear on views, but that was using rails 1.2 and using >> scaffold in the controller. I''m running rails 2.3.x, so wasn''t able to >> use "scaffold" in the way described in the book. >> >> Does that explain the (mis)behavior? > > Which version of the book have you got?! If it''s v2 or earlier, lots > of it is going to be wrong for the version you have installed, which > is going to be very frustrating at times.2nd edition, 2006.> > > But yes - the scaffolding used to loop through all the columns : > > <% for column in License.content_columns %> > <p> > <b><%= column.human_name %>:</b> <%=h @license.send(column.name) %> > </p> > <% end %> > > ...but that''s intensely annoying because you have to *totally* remove > it to replace it with anything useful. > > Now, the individual fields get rendered one after an other - so you > can tweak the scaffolded file, rather than re-write it completely. > > (of course the down side is if you add a new field to the db, you have > to add it to the view)Thank you. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder wrote:> On Tue, Mar 16, 2010 at 7:55 AM, Jeff Ramin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > >> According to "Agile Web Development with Rails", the field should >> automagically appear on views, but that was using rails 1.2 and using >> scaffold in the controller. I''m running rails 2.3.x, so wasn''t able to >> use "scaffold" in the way described in the book. > > You''re setting yourself up for continuous pain and frustration by using > an out-of-date reference with a current Rails version. > > Toss that book and get the latest, or use online tutorials based on the > 2.3.x branch. Really. > > -- > Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > twitter: @hassanOk - thanks for the warning. Are there online tutorials you would recommend, for an experienced Java programmer who is new to ruby and rails? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Mar 16, 2010 at 8:19 AM, Jeff Ramin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Are there online tutorials you would recommend, for an experienced Java > programmer who is new to ruby and rails?Coming from a similar background, I''ve gotten a lot out of: http://guides.rubyonrails.org/ http://railscasts.com/ http://peepcode.com/ and of course hanging out here and on the #ror irc channel :-) HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.