Hi!
I used scaffold to create my mvc for my table. I have only written
one other ROR application, and since I was winging it, I didn''t take
advantage of the rails-generate code.
My scenario is:
User clicks save on form, and is redirected to the "show" view where
they see what they just saved. Code is this:
<% session[:ward_id] = @ward %>
<p>
<% for column in Ward.content_columns %>
<b><%= column.human_name %>:</b>
<% if column.null == "true" %>
<% else %>
<%=h @ward.send(column.name) %>
<% end %>
</p>
<% end %>
My error is that beloved "you have a nil object when you didn''t
expect
it!"
I am trying to check for nil values and have it just display nothing
but the human_name when it hits a nil. I have tried many different
combinations and can''t seem to get it right. Any direction or
suggestion is always appreciated!!
Thank you!!
~~Ali
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
On Mar 12, 10:57 pm, "Ali" <awilli...-KQhSGARDxiOeQVqA2Ba1Pg@public.gmane.org> wrote:> [code snip] > > My error is that beloved "you have a nil object when you didn''t expect > it!" > I am trying to check for nil values and have it just display nothing > but the human_name when it hits a nil. I have tried many different > combinations and can''t seem to get it right. Any direction or > suggestion is always appreciated!! > > Thank you!! > ~~AliProbably you don''t pass the id parameter to the ''show'' controller You have to do something like this after the creation of the object: redirect_to :action => ''show'', :id => myobject.id --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Mar 12, 3:03 pm, "Trochalakis Christos" <yati...-9B1QEYbJDnYJ0qhBuY+7KQ@public.gmane.org> wrote:> On Mar 12, 10:57 pm, "Ali" <awilli...-KQhSGARDxiOeQVqA2Ba1Pg@public.gmane.org> wrote: > > > [codesnip] > > > My error is that beloved "you have a nil object when you didn''t expect > > it!" > > I am trying to check for nil values and have it just display nothing > > but the human_name when it hits a nil. I have tried many different > > combinations and can''t seem to get it right. Any direction or > > suggestion is always appreciated!! > > > Thank you!! > > ~~Ali > > Probably you don''t pass the id parameter to the ''show'' controller > > You have to do something like this after the creation of the object: > > redirect_to :action => ''show'', :id => myobject.idYep, that did it!! Thanks a bunch!! ~Ali --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---