I am having problems trying to get the output to work in an
application I have. Here is the example
THIS GIVES ME THE CORRECT VALUES
 <!-- ######## Flooring ######### -->
                  <% if(params[:flooring]) %>
                    <tr><td
colspan="4"><h2>Flooring</h2></td></tr>
                    <% for company in @companies %>
                          <% if(company.flooring == 1)
%>
                        <tr>
                          <td><%= link_to  company.name, company
%></
td>
                          <!--" +
image_tag(''view2.gif'', :border =>
''0'') + "-->
 
<% if session[:user_id] %>
                            <td><%= link_to  "[old view]",
:controller
=> "companies", :action=> "show_org", :id =>
company.id %></td>
                            <td><%= link_to "[edit]",
edit_company_path(company) %></td>
                            <td><%= link_to "[delete]",
company, :confirm => ''Are you sure?'', :method => :delete
%></td>
                          <% end %>
                  <% end %>
                      </tr>
                    <% end %>
                  <% end %>
THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT
<!-- ######## Outdoor ######### -->
                  <% if(params[:outdoor]) %>
                    <tr><td
colspan="4"><h2>Outdoor</h2></td></tr>
                    <% for company in @companies %>
                      <%=h company.outdoor_wood_based_products %>
                          <% if(company.outdoor_wood_based_products =1 ||
company.outdoor_non_wood_based_products == 1) %>
                        <tr>
                          <td><%= link_to  company.name, company
%></
td>
                          <!--" +
image_tag(''view2.gif'', :border =>
''0'') + "-->
                            <% if session[:user_id] %>
                            <td><%= link_to  "[old view]",
:controller
=> "companies", :action=> "show_org", :id =>
company.id %></td>
                            <td><%= link_to "[edit]",
edit_company_path(company) %></td>
                            <td><%= link_to "[delete]",
company, :confirm => ''Are you sure?'', :method => :delete
%></td>
                          <% end %>
                  <% end %>
                      </tr>
                    <% end %>
                  <% end %>
could it be something in a model or controller
--~--~---------~--~----~------------~-------~--~----~
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''m guessing company.wood_based_products is an object or array or something other than a string? If you see "#" on your page check the page source and see if there''s more there, like #<Company: id: 1223...>, with everything in brackets hidden because it''s treated as an xml tag. If that''s the case it should help you figure out what your problem is, probably trying to output something that isn''t a string. On May 28, 10:00 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am having problems trying to get the output to work in an > application I have. Here is the example > > THIS GIVES ME THE CORRECT VALUES > <!-- ######## Flooring ######### --> > <% if(params[:flooring]) %> > <tr><td colspan="4"><h2>Flooring</h2></td></tr> > <% for company in @companies %> > <% if(company.flooring == 1) > %> > <tr> > <td><%= link_to company.name, company %></ > td> > <!--" + image_tag(''view2.gif'', :border => > ''0'') + "--> > > <% if session[:user_id] %> > <td><%= link_to "[old view]", :controller > => "companies", :action=> "show_org", :id => company.id %></td> > <td><%= link_to "[edit]", > edit_company_path(company) %></td> > <td><%= link_to "[delete]", > company, :confirm => ''Are you sure?'', :method => :delete %></td> > <% end %> > <% end %> > </tr> > <% end %> > <% end %> > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT > <!-- ######## Outdoor ######### --> > <% if(params[:outdoor]) %> > <tr><td colspan="4"><h2>Outdoor</h2></td></tr> > <% for company in @companies %> > > <%=h company.outdoor_wood_based_products %> > <% if(company.outdoor_wood_based_products => 1 || company.outdoor_non_wood_based_products == 1) %> > <tr> > <td><%= link_to company.name, company %></ > td> > <!--" + image_tag(''view2.gif'', :border => > ''0'') + "--> > <% if session[:user_id] %> > <td><%= link_to "[old view]", :controller > => "companies", :action=> "show_org", :id => company.id %></td> > <td><%= link_to "[edit]", > edit_company_path(company) %></td> > <td><%= link_to "[delete]", > company, :confirm => ''Are you sure?'', :method => :delete %></td> > <% end %> > <% end %> > </tr> > <% end %> > <% end %> > > could it be something in a model or controller--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
company.wood_based_products is a field in the database that holds either a 1 or a 0. On May 28, 12:51 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m guessing company.wood_based_products is an object or array or > something other than a string? > > If you see "#" on your page check the page source and see if there''s > more there, like #<Company: id: 1223...>, > with everything in brackets hidden because it''s treated as an xml tag. > > If that''s the case it should help you figure out what your problem is, > probably trying to > output something that isn''t a string. > > On May 28, 10:00 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I am having problems trying to get the output to work in an > > application I have. Here is the example > > > THIS GIVES ME THE CORRECT VALUES > > <!-- ######## Flooring ######### --> > > <% if(params[:flooring]) %> > > <tr><td colspan="4"><h2>Flooring</h2></td></tr> > > <% for company in @companies %> > > <% if(company.flooring == 1) > > %> > > <tr> > > <td><%= link_to company.name, company %></ > > td> > > <!--" + image_tag(''view2.gif'', :border => > > ''0'') + "--> > > > <% if session[:user_id] %> > > <td><%= link_to "[old view]", :controller > > => "companies", :action=> "show_org", :id => company.id %></td> > > <td><%= link_to "[edit]", > > edit_company_path(company) %></td> > > <td><%= link_to "[delete]", > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > <% end %> > > <% end %> > > </tr> > > <% end %> > > <% end %> > > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT > > <!-- ######## Outdoor ######### --> > > <% if(params[:outdoor]) %> > > <tr><td colspan="4"><h2>Outdoor</h2></td></tr> > > <% for company in @companies %> > > > <%=h company.outdoor_wood_based_products %> > > <% if(company.outdoor_wood_based_products => > 1 || company.outdoor_non_wood_based_products == 1) %> > > <tr> > > <td><%= link_to company.name, company %></ > > td> > > <!--" + image_tag(''view2.gif'', :border => > > ''0'') + "--> > > <% if session[:user_id] %> > > <td><%= link_to "[old view]", :controller > > => "companies", :action=> "show_org", :id => company.id %></td> > > <td><%= link_to "[edit]", > > edit_company_path(company) %></td> > > <td><%= link_to "[delete]", > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > <% end %> > > <% end %> > > </tr> > > <% end %> > > <% end %> > > > could it be something in a model or controller--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I am trying to test to see if it is a 1 and if so then to display
details
  <%=h company.outdoor_wood_based_products %>
                          <% if(company.outdoor_wood_based_products =1 ||
company.outdoor_non_wood_based_products == 1) %>
gives me the following:
#<OutdoorWoodBasedProduct:0x1b07392>  #<OutdoorWoodBasedProduct:
0x193973d>  #<OutdoorWoodBasedProduct:
0x14346a4>#<OutdoorWoodBasedProduct:
0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97>
#<OutdoorWoodBasedProduct:0x17d40b7>  #<OutdoorWoodBasedProduct:
0x1a52e8f>  #<OutdoorWoodBasedProduct:
0x36c862>#<OutdoorWoodBasedProduct:0x9da031>
#<OutdoorWoodBasedProduct:0x7272ca>  #<OutdoorWoodBasedProduct:
0x11e7bb1>  #<OutdoorWoodBasedProduct:0x58694a>
#<OutdoorWoodBasedProduct:0x10c6ab0>  #<OutdoorWoodBasedProduct:
0x1162955>  #<OutdoorWoodBasedProduct:0x31a99a>
#<OutdoorWoodBasedProduct:0x13ebb53>  #<OutdoorWoodBasedProduct:
0x1b45d04>
On May 28, 1:11 pm, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> company.wood_based_products is a field in the database that holds
> either a 1 or a 0.
>
> On May 28, 12:51 pm, JDevine
<johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > I''m guessing company.wood_based_products is an object or
array or
> > something other than a string?
>
> > If you see "#" on your page check the page source and see if
there''s
> > more there, like #<Company: id: 1223...>,
> > with everything in brackets hidden because it''s treated as an
xml tag.
>
> > If that''s the case it should help you figure out what your
problem is,
> > probably trying to
> > output something that isn''t a string.
>
> > On May 28, 10:00 am, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > I am having problems trying to get the output to work in an
> > > application I have. Here is the example
>
> > > THIS GIVES ME THE CORRECT VALUES
> > >  <!-- ######## Flooring ######### -->
> > >                   <% if(params[:flooring]) %>
> > >                     <tr><td
colspan="4"><h2>Flooring</h2></td></tr>
> > >                     <% for company in @companies %>
> > >                           <% if(company.flooring == 1)
> > > %>
> > >                         <tr>
> > >                           <td><%= link_to  company.name,
company %></
> > > td>
> > >                           <!--" +
image_tag(''view2.gif'', :border =>
> > > ''0'') + "-->
>
> > > <% if session[:user_id] %>
> > >                             <td><%= link_to  "[old
view]", :controller
> > > => "companies", :action=> "show_org",
:id => company.id %></td>
> > >                             <td><%= link_to
"[edit]",
> > > edit_company_path(company) %></td>
> > >                             <td><%= link_to
"[delete]",
> > > company, :confirm => ''Are you sure?'',
:method => :delete %></td>
> > >                           <% end %>
> > >                   <% end %>
> > >                       </tr>
> > >                     <% end %>
> > >                   <% end %>
>
> > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT
> > > <!-- ######## Outdoor ######### -->
> > >                   <% if(params[:outdoor]) %>
> > >                     <tr><td
colspan="4"><h2>Outdoor</h2></td></tr>
> > >                     <% for company in @companies %>
>
> > >                       <%=h company.outdoor_wood_based_products
%>
> > >                           <%
if(company.outdoor_wood_based_products => > > 1 ||
company.outdoor_non_wood_based_products == 1) %>
> > >                         <tr>
> > >                           <td><%= link_to  company.name,
company %></
> > > td>
> > >                           <!--" +
image_tag(''view2.gif'', :border =>
> > > ''0'') + "-->
> > >                             <% if session[:user_id] %>
> > >                             <td><%= link_to  "[old
view]", :controller
> > > => "companies", :action=> "show_org",
:id => company.id %></td>
> > >                             <td><%= link_to
"[edit]",
> > > edit_company_path(company) %></td>
> > >                             <td><%= link_to
"[delete]",
> > > company, :confirm => ''Are you sure?'',
:method => :delete %></td>
> > >                           <% end %>
> > >                   <% end %>
> > >                       </tr>
> > >                     <% end %>
> > >                   <% end %>
>
> > > could it be something in a model or controller
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Well without , obviously you''re outputting an OutdoorWoodBasedProduct model somewhere repeatedly, or a collection of them -- my guess is <%=h company.outdoor_wood_based_products %>. If that really is 1 or 0, then I don''t know if I can help. Do you have both a field and an association by the same name? If you go into script/console, what is the output for: Company.find(:first).outdoor_wood_based_products On May 28, 11:16 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am trying to test to see if it is a 1 and if so then to display > details > > <%=h company.outdoor_wood_based_products %> > <% if(company.outdoor_wood_based_products => 1 || company.outdoor_non_wood_based_products == 1) %> > > gives me the following: > > #<OutdoorWoodBasedProduct:0x1b07392> #<OutdoorWoodBasedProduct: > 0x193973d> #<OutdoorWoodBasedProduct: > 0x14346a4>#<OutdoorWoodBasedProduct: > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97> > #<OutdoorWoodBasedProduct:0x17d40b7> #<OutdoorWoodBasedProduct: > 0x1a52e8f> #<OutdoorWoodBasedProduct: > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031> > #<OutdoorWoodBasedProduct:0x7272ca> #<OutdoorWoodBasedProduct: > 0x11e7bb1> #<OutdoorWoodBasedProduct:0x58694a> > #<OutdoorWoodBasedProduct:0x10c6ab0> #<OutdoorWoodBasedProduct: > 0x1162955> #<OutdoorWoodBasedProduct:0x31a99a> > #<OutdoorWoodBasedProduct:0x13ebb53> #<OutdoorWoodBasedProduct: > 0x1b45d04> > > On May 28, 1:11 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > company.wood_based_products is a field in the database that holds > > either a 1 or a 0. > > > On May 28, 12:51 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I''m guessing company.wood_based_products is an object or array or > > > something other than a string? > > > > If you see "#" on your page check the page source and see if there''s > > > more there, like #<Company: id: 1223...>, > > > with everything in brackets hidden because it''s treated as an xml tag. > > > > If that''s the case it should help you figure out what your problem is, > > > probably trying to > > > output something that isn''t a string. > > > > On May 28, 10:00 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I am having problems trying to get the output to work in an > > > > application I have. Here is the example > > > > > THIS GIVES ME THE CORRECT VALUES > > > > <!-- ######## Flooring ######### --> > > > > <% if(params[:flooring]) %> > > > > <tr><td colspan="4"><h2>Flooring</h2></td></tr> > > > > <% for company in @companies %> > > > > <% if(company.flooring == 1) > > > > %> > > > > <tr> > > > > <td><%= link_to company.name, company %></ > > > > td> > > > > <!--" + image_tag(''view2.gif'', :border => > > > > ''0'') + "--> > > > > > <% if session[:user_id] %> > > > > <td><%= link_to "[old view]", :controller > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > <td><%= link_to "[edit]", > > > > edit_company_path(company) %></td> > > > > <td><%= link_to "[delete]", > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > <% end %> > > > > <% end %> > > > > </tr> > > > > <% end %> > > > > <% end %> > > > > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT > > > > <!-- ######## Outdoor ######### --> > > > > <% if(params[:outdoor]) %> > > > > <tr><td colspan="4"><h2>Outdoor</h2></td></tr> > > > > <% for company in @companies %> > > > > > <%=h company.outdoor_wood_based_products %> > > > > <% if(company.outdoor_wood_based_products => > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > <tr> > > > > <td><%= link_to company.name, company %></ > > > > td> > > > > <!--" + image_tag(''view2.gif'', :border => > > > > ''0'') + "--> > > > > <% if session[:user_id] %> > > > > <td><%= link_to "[old view]", :controller > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > <td><%= link_to "[edit]", > > > > edit_company_path(company) %></td> > > > > <td><%= link_to "[delete]", > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > <% end %> > > > > <% end %> > > > > </tr> > > > > <% end %> > > > > <% end %> > > > > > could it be something in a model or controller--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What do you mean by a "field and an association by the same name" I have a company table in my DB with a field called outdoor_wood_based_products not sure I have a script console. I am new to this as you can tell and I am running Netbeans 6 with ruby as a plugin On May 28, 1:41 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Well without , obviously you''re outputting an OutdoorWoodBasedProduct > model somewhere repeatedly, > or a collection of them -- my guess is <%=h > company.outdoor_wood_based_products %>. > > If that really is 1 or 0, then I don''t know if I can help. > > Do you have both a field and an association by the same name? > > If you go into script/console, what is the output for: > > Company.find(:first).outdoor_wood_based_products > > On May 28, 11:16 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I am trying to test to see if it is a 1 and if so then to display > > details > > > <%=h company.outdoor_wood_based_products %> > > <% if(company.outdoor_wood_based_products => > 1 || company.outdoor_non_wood_based_products == 1) %> > > > gives me the following: > > > #<OutdoorWoodBasedProduct:0x1b07392> #<OutdoorWoodBasedProduct: > > 0x193973d> #<OutdoorWoodBasedProduct: > > 0x14346a4>#<OutdoorWoodBasedProduct: > > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97> > > #<OutdoorWoodBasedProduct:0x17d40b7> #<OutdoorWoodBasedProduct: > > 0x1a52e8f> #<OutdoorWoodBasedProduct: > > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031> > > #<OutdoorWoodBasedProduct:0x7272ca> #<OutdoorWoodBasedProduct: > > 0x11e7bb1> #<OutdoorWoodBasedProduct:0x58694a> > > #<OutdoorWoodBasedProduct:0x10c6ab0> #<OutdoorWoodBasedProduct: > > 0x1162955> #<OutdoorWoodBasedProduct:0x31a99a> > > #<OutdoorWoodBasedProduct:0x13ebb53> #<OutdoorWoodBasedProduct: > > 0x1b45d04> > > > On May 28, 1:11 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > company.wood_based_products is a field in the database that holds > > > either a 1 or a 0. > > > > On May 28, 12:51 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I''m guessing company.wood_based_products is an object or array or > > > > something other than a string? > > > > > If you see "#" on your page check the page source and see if there''s > > > > more there, like #<Company: id: 1223...>, > > > > with everything in brackets hidden because it''s treated as an xml tag. > > > > > If that''s the case it should help you figure out what your problem is, > > > > probably trying to > > > > output something that isn''t a string. > > > > > On May 28, 10:00 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I am having problems trying to get the output to work in an > > > > > application I have. Here is the example > > > > > > THIS GIVES ME THE CORRECT VALUES > > > > > <!-- ######## Flooring ######### --> > > > > > <% if(params[:flooring]) %> > > > > > <tr><td colspan="4"><h2>Flooring</h2></td></tr> > > > > > <% for company in @companies %> > > > > > <% if(company.flooring == 1) > > > > > %> > > > > > <tr> > > > > > <td><%= link_to company.name, company %></ > > > > > td> > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > ''0'') + "--> > > > > > > <% if session[:user_id] %> > > > > > <td><%= link_to "[old view]", :controller > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > <td><%= link_to "[edit]", > > > > > edit_company_path(company) %></td> > > > > > <td><%= link_to "[delete]", > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > <% end %> > > > > > <% end %> > > > > > </tr> > > > > > <% end %> > > > > > <% end %> > > > > > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT > > > > > <!-- ######## Outdoor ######### --> > > > > > <% if(params[:outdoor]) %> > > > > > <tr><td colspan="4"><h2>Outdoor</h2></td></tr> > > > > > <% for company in @companies %> > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > <% if(company.outdoor_wood_based_products => > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > <tr> > > > > > <td><%= link_to company.name, company %></ > > > > > td> > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > ''0'') + "--> > > > > > <% if session[:user_id] %> > > > > > <td><%= link_to "[old view]", :controller > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > <td><%= link_to "[edit]", > > > > > edit_company_path(company) %></td> > > > > > <td><%= link_to "[delete]", > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > <% end %> > > > > > <% end %> > > > > > </tr> > > > > > <% end %> > > > > > <% end %> > > > > > > could it be something in a model or controller--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think the field and association may be my issue if I can figure out what you mean On May 28, 1:49 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What do you mean by a "field and an association by the same name" > > I have a company table in my DB with a field called > outdoor_wood_based_products > > not sure I have a script console. I am new to this as you can tell and > I am running Netbeans 6 with ruby as a plugin > > On May 28, 1:41 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Well without , obviously you''re outputting an OutdoorWoodBasedProduct > > model somewhere repeatedly, > > or a collection of them -- my guess is <%=h > > company.outdoor_wood_based_products %>. > > > If that really is 1 or 0, then I don''t know if I can help. > > > Do you have both a field and an association by the same name? > > > If you go into script/console, what is the output for: > > > Company.find(:first).outdoor_wood_based_products > > > On May 28, 11:16 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I am trying to test to see if it is a 1 and if so then to display > > > details > > > > <%=h company.outdoor_wood_based_products %> > > > <% if(company.outdoor_wood_based_products => > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > gives me the following: > > > > #<OutdoorWoodBasedProduct:0x1b07392> #<OutdoorWoodBasedProduct: > > > 0x193973d> #<OutdoorWoodBasedProduct: > > > 0x14346a4>#<OutdoorWoodBasedProduct: > > > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97> > > > #<OutdoorWoodBasedProduct:0x17d40b7> #<OutdoorWoodBasedProduct: > > > 0x1a52e8f> #<OutdoorWoodBasedProduct: > > > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031> > > > #<OutdoorWoodBasedProduct:0x7272ca> #<OutdoorWoodBasedProduct: > > > 0x11e7bb1> #<OutdoorWoodBasedProduct:0x58694a> > > > #<OutdoorWoodBasedProduct:0x10c6ab0> #<OutdoorWoodBasedProduct: > > > 0x1162955> #<OutdoorWoodBasedProduct:0x31a99a> > > > #<OutdoorWoodBasedProduct:0x13ebb53> #<OutdoorWoodBasedProduct: > > > 0x1b45d04> > > > > On May 28, 1:11 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > company.wood_based_products is a field in the database that holds > > > > either a 1 or a 0. > > > > > On May 28, 12:51 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I''m guessing company.wood_based_products is an object or array or > > > > > something other than a string? > > > > > > If you see "#" on your page check the page source and see if there''s > > > > > more there, like #<Company: id: 1223...>, > > > > > with everything in brackets hidden because it''s treated as an xml tag. > > > > > > If that''s the case it should help you figure out what your problem is, > > > > > probably trying to > > > > > output something that isn''t a string. > > > > > > On May 28, 10:00 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I am having problems trying to get the output to work in an > > > > > > application I have. Here is the example > > > > > > > THIS GIVES ME THE CORRECT VALUES > > > > > > <!-- ######## Flooring ######### --> > > > > > > <% if(params[:flooring]) %> > > > > > > <tr><td colspan="4"><h2>Flooring</h2></td></tr> > > > > > > <% for company in @companies %> > > > > > > <% if(company.flooring == 1) > > > > > > %> > > > > > > <tr> > > > > > > <td><%= link_to company.name, company %></ > > > > > > td> > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > ''0'') + "--> > > > > > > > <% if session[:user_id] %> > > > > > > <td><%= link_to "[old view]", :controller > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > <td><%= link_to "[edit]", > > > > > > edit_company_path(company) %></td> > > > > > > <td><%= link_to "[delete]", > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > <% end %> > > > > > > <% end %> > > > > > > </tr> > > > > > > <% end %> > > > > > > <% end %> > > > > > > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT > > > > > > <!-- ######## Outdoor ######### --> > > > > > > <% if(params[:outdoor]) %> > > > > > > <tr><td colspan="4"><h2>Outdoor</h2></td></tr> > > > > > > <% for company in @companies %> > > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > > <% if(company.outdoor_wood_based_products => > > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > > <tr> > > > > > > <td><%= link_to company.name, company %></ > > > > > > td> > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > ''0'') + "--> > > > > > > <% if session[:user_id] %> > > > > > > <td><%= link_to "[old view]", :controller > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > <td><%= link_to "[edit]", > > > > > > edit_company_path(company) %></td> > > > > > > <td><%= link_to "[delete]", > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > <% end %> > > > > > > <% end %> > > > > > > </tr> > > > > > > <% end %> > > > > > > <% end %> > > > > > > > could it be something in a model or controller--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I did change some filed names manually instead of using the migration tool On May 28, 1:54 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I think the field and association may be my issue if I can figure out > what you mean > > On May 28, 1:49 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > What do you mean by a "field and an association by the same name" > > > I have a company table in my DB with a field called > > outdoor_wood_based_products > > > not sure I have a script console. I am new to this as you can tell and > > I am running Netbeans 6 with ruby as a plugin > > > On May 28, 1:41 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Well without , obviously you''re outputting an OutdoorWoodBasedProduct > > > model somewhere repeatedly, > > > or a collection of them -- my guess is <%=h > > > company.outdoor_wood_based_products %>. > > > > If that really is 1 or 0, then I don''t know if I can help. > > > > Do you have both a field and an association by the same name? > > > > If you go into script/console, what is the output for: > > > > Company.find(:first).outdoor_wood_based_products > > > > On May 28, 11:16 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I am trying to test to see if it is a 1 and if so then to display > > > > details > > > > > <%=h company.outdoor_wood_based_products %> > > > > <% if(company.outdoor_wood_based_products => > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > gives me the following: > > > > > #<OutdoorWoodBasedProduct:0x1b07392> #<OutdoorWoodBasedProduct: > > > > 0x193973d> #<OutdoorWoodBasedProduct: > > > > 0x14346a4>#<OutdoorWoodBasedProduct: > > > > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97> > > > > #<OutdoorWoodBasedProduct:0x17d40b7> #<OutdoorWoodBasedProduct: > > > > 0x1a52e8f> #<OutdoorWoodBasedProduct: > > > > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031> > > > > #<OutdoorWoodBasedProduct:0x7272ca> #<OutdoorWoodBasedProduct: > > > > 0x11e7bb1> #<OutdoorWoodBasedProduct:0x58694a> > > > > #<OutdoorWoodBasedProduct:0x10c6ab0> #<OutdoorWoodBasedProduct: > > > > 0x1162955> #<OutdoorWoodBasedProduct:0x31a99a> > > > > #<OutdoorWoodBasedProduct:0x13ebb53> #<OutdoorWoodBasedProduct: > > > > 0x1b45d04> > > > > > On May 28, 1:11 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > company.wood_based_products is a field in the database that holds > > > > > either a 1 or a 0. > > > > > > On May 28, 12:51 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I''m guessing company.wood_based_products is an object or array or > > > > > > something other than a string? > > > > > > > If you see "#" on your page check the page source and see if there''s > > > > > > more there, like #<Company: id: 1223...>, > > > > > > with everything in brackets hidden because it''s treated as an xml tag. > > > > > > > If that''s the case it should help you figure out what your problem is, > > > > > > probably trying to > > > > > > output something that isn''t a string. > > > > > > > On May 28, 10:00 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > I am having problems trying to get the output to work in an > > > > > > > application I have. Here is the example > > > > > > > > THIS GIVES ME THE CORRECT VALUES > > > > > > > <!-- ######## Flooring ######### --> > > > > > > > <% if(params[:flooring]) %> > > > > > > > <tr><td colspan="4"><h2>Flooring</h2></td></tr> > > > > > > > <% for company in @companies %> > > > > > > > <% if(company.flooring == 1) > > > > > > > %> > > > > > > > <tr> > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > td> > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > ''0'') + "--> > > > > > > > > <% if session[:user_id] %> > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > <td><%= link_to "[edit]", > > > > > > > edit_company_path(company) %></td> > > > > > > > <td><%= link_to "[delete]", > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > <% end %> > > > > > > > <% end %> > > > > > > > </tr> > > > > > > > <% end %> > > > > > > > <% end %> > > > > > > > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT > > > > > > > <!-- ######## Outdoor ######### --> > > > > > > > <% if(params[:outdoor]) %> > > > > > > > <tr><td colspan="4"><h2>Outdoor</h2></td></tr> > > > > > > > <% for company in @companies %> > > > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > > > <% if(company.outdoor_wood_based_products => > > > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > > > <tr> > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > td> > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > ''0'') + "--> > > > > > > > <% if session[:user_id] %> > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > <td><%= link_to "[edit]", > > > > > > > edit_company_path(company) %></td> > > > > > > > <td><%= link_to "[delete]", > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > <% end %> > > > > > > > <% end %> > > > > > > > </tr> > > > > > > > <% end %> > > > > > > > <% end %> > > > > > > > > could it be something in a model or controller--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
By a "field and an association by the same name" I mean do you have a
field in your database table named
''outdoor_wood_based_products'' as
well as an association in your model ("has_many",
"has_and_belongs_to_many", etc) that is also called
''outdoor_wood_based_products''.
In a console window (cmd if you''re on Windows, or terminal if
you''re
on UNIX/Mac), navigate to your base Rails project directory (c:/
myproject),
and type "ruby script/console". That gives you an interactive ruby
session with all the same
libraries loaded as your webserver would see. That way you can create
objects, call methods etc interactively through ruby
without going through the browser.
Try that (it''s an indispensable tool as you''re developing),
Also paste in your Company.rb model so I can see what''s going on, as
well as the companies database schema definition.
On May 28, 11:49 am, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> What do you mean by a "field and an association by the same name"
>
> I have a company table in my DB with a field called
> outdoor_wood_based_products
>
> not sure I have a script console. I am new to this as you can tell and
> I am running Netbeans 6 with ruby as a plugin
>
> On May 28, 1:41 pm, JDevine
<johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > Well without , obviously you''re outputting an
OutdoorWoodBasedProduct
> > model somewhere repeatedly,
> > or a collection of them -- my guess is <%=h
> > company.outdoor_wood_based_products %>.
>
> > If that really is 1 or 0, then I don''t know if I can help.
>
> > Do you have both a field and an association by the same name?
>
> > If you go into script/console, what is the output for:
>
> > Company.find(:first).outdoor_wood_based_products
>
> > On May 28, 11:16 am, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > I am trying to test to see if it is a 1 and if so then to display
> > > details
>
> > >   <%=h company.outdoor_wood_based_products %>
> > >                           <%
if(company.outdoor_wood_based_products => > > 1 ||
company.outdoor_non_wood_based_products == 1) %>
>
> > > gives me the following:
>
> > > #<OutdoorWoodBasedProduct:0x1b07392> 
#<OutdoorWoodBasedProduct:
> > > 0x193973d>  #<OutdoorWoodBasedProduct:
> > > 0x14346a4>#<OutdoorWoodBasedProduct:
> > > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97>
> > > #<OutdoorWoodBasedProduct:0x17d40b7> 
#<OutdoorWoodBasedProduct:
> > > 0x1a52e8f>  #<OutdoorWoodBasedProduct:
> > > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031>
> > > #<OutdoorWoodBasedProduct:0x7272ca> 
#<OutdoorWoodBasedProduct:
> > > 0x11e7bb1>  #<OutdoorWoodBasedProduct:0x58694a>
> > > #<OutdoorWoodBasedProduct:0x10c6ab0> 
#<OutdoorWoodBasedProduct:
> > > 0x1162955>  #<OutdoorWoodBasedProduct:0x31a99a>
> > > #<OutdoorWoodBasedProduct:0x13ebb53> 
#<OutdoorWoodBasedProduct:
> > > 0x1b45d04>
>
> > > On May 28, 1:11 pm, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > company.wood_based_products is a field in the database that
holds
> > > > either a 1 or a 0.
>
> > > > On May 28, 12:51 pm, JDevine
<johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > > I''m guessing company.wood_based_products is an
object or array or
> > > > > something other than a string?
>
> > > > > If you see "#" on your page check the page
source and see if there''s
> > > > > more there, like #<Company: id: 1223...>,
> > > > > with everything in brackets hidden because
it''s treated as an xml tag.
>
> > > > > If that''s the case it should help you figure
out what your problem is,
> > > > > probably trying to
> > > > > output something that isn''t a string.
>
> > > > > On May 28, 10:00 am, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > > > I am having problems trying to get the output to
work in an
> > > > > > application I have. Here is the example
>
> > > > > > THIS GIVES ME THE CORRECT VALUES
> > > > > >  <!-- ######## Flooring ######### -->
> > > > > >                   <% if(params[:flooring])
%>
> > > > > >                     <tr><td
colspan="4"><h2>Flooring</h2></td></tr>
> > > > > >                     <% for company in
@companies %>
> > > > > >                           <%
if(company.flooring == 1)
> > > > > > %>
> > > > > >                         <tr>
> > > > > >                           <td><%= link_to
company.name, company %></
> > > > > > td>
> > > > > >                           <!--" +
image_tag(''view2.gif'', :border =>
> > > > > > ''0'') + "-->
>
> > > > > > <% if session[:user_id] %>
> > > > > >                             <td><%=
link_to  "[old view]", :controller
> > > > > > => "companies", :action=>
"show_org", :id => company.id %></td>
> > > > > >                             <td><%=
link_to "[edit]",
> > > > > > edit_company_path(company) %></td>
> > > > > >                             <td><%=
link_to "[delete]",
> > > > > > company, :confirm => ''Are you
sure?'', :method => :delete %></td>
> > > > > >                           <% end %>
> > > > > >                   <% end %>
> > > > > >                       </tr>
> > > > > >                     <% end %>
> > > > > >                   <% end %>
>
> > > > > > THIS GIVES ME "#" INSTEAD OF THE CORRECT
OUTPUT
> > > > > > <!-- ######## Outdoor ######### -->
> > > > > >                   <% if(params[:outdoor]) %>
> > > > > >                     <tr><td
colspan="4"><h2>Outdoor</h2></td></tr>
> > > > > >                     <% for company in
@companies %>
>
> > > > > >                       <%=h
company.outdoor_wood_based_products %>
> > > > > >                           <%
if(company.outdoor_wood_based_products => > > > > > 1 ||
company.outdoor_non_wood_based_products == 1) %>
> > > > > >                         <tr>
> > > > > >                           <td><%= link_to
company.name, company %></
> > > > > > td>
> > > > > >                           <!--" +
image_tag(''view2.gif'', :border =>
> > > > > > ''0'') + "-->
> > > > > >                             <% if
session[:user_id] %>
> > > > > >                             <td><%=
link_to  "[old view]", :controller
> > > > > > => "companies", :action=>
"show_org", :id => company.id %></td>
> > > > > >                             <td><%=
link_to "[edit]",
> > > > > > edit_company_path(company) %></td>
> > > > > >                             <td><%=
link_to "[delete]",
> > > > > > company, :confirm => ''Are you
sure?'', :method => :delete %></td>
> > > > > >                           <% end %>
> > > > > >                   <% end %>
> > > > > >                       </tr>
> > > > > >                     <% end %>
> > > > > >                   <% end %>
>
> > > > > > could it be something in a model or controller
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
MODEL for company
class Company < ActiveRecord::Base
  has_many :facilities
  has_many :green_products
  has_many :discontinued_markets
  has_many :wood_based_building_system_products
  has_many :non_wood_based_building_system_products
  has_many :wood_windows_doors_products
  has_many :non_wood_windows_and_doors_products
  has_many :millwork_products
  has_many :wood_based_panel_products
  has_many :flooring_products
  has_many :cabinetry_and_furniture_products
  has_many :outdoor_wood_based_products
  has_many :outdoor_non_wood_based_products
  has_many :other_wood_based_building_products
  has_many :other_non_wood_based_building_products
  has_many :stone_processed_products_products
  has_many :insulation_products
  after_update :save_facilities
  after_update :save_green_products
  after_update :save_discontinued_markets
  after_update :save_wood_based_building_system_products
  after_update :save_non_wood_based_building_system_products
  after_update :save_wood_windows_doors_products
  after_update :save_non_wood_windows_and_doors_products
  after_update :save_millwork_products
  after_update :save_wood_based_panel_products
  after_update :save_flooring_products
  after_update :save_cabinetry_and_furniture_products
  after_update :save_outdoor_wood_based_products
  after_update :save_outdoor_non_wood_based_products
  after_update :save_other_wood_based_building_products
  after_update :save_other_non_wood_based_building_products
  after_update :save_stone_processed_products_products
  after_update :save_insulation_products
  def self.search(search)
    if search[:test]
      province = search.delete(:province)
      test = search.delete(:test)
      action = search.delete(:action)
      controller = search.delete(:controller)
      topdelcheckbox = search.delete(:topdelcheckbox)
      sql = "0=0 and province LIKE ?"
      varlength = search.length
      counter = 1
      if (varlength == 1)
        sql += " and "
      end
      if (varlength >= 2)
        sql += " and ("
      end
      search.each do |key, val|
        if(key != "province")
          if(key == "building_systems")
            sql += "wood_based_building_systems = 1 or
non_wood_based_building_system = 1"
          elsif(key == "windows_and_doors")
            sql += "wood_windows_and_doors = 1 or
non_wood_windows_and_doors = 1"
          elsif(key == "outdoor")
            sql += "outdoor_wood_based_products = 1 or
outdoor_non_wood_based_products = 1"
          elsif(key == "other_building_products")
            sql += "other_wood_based_building_products = 1 or
other_non_wood_based_building_products = 1"
          elsif(key == "wood_based_panels")
            sql += "wood_based_panels = 1"
          elsif(key == "millwork")
            sql += "millwork = 1"
          elsif(key == "cabinetry_and_furniture")
            sql += "cabinetry_and_furniture = 1"
          elsif(key == "flooring")
            sql += "flooring = 1"
          elsif(key == "stone_processed_products")
            sql += "stone_processed_products = 1"
          elsif(key == "insulation")
            sql += "insulation = 1"
          end
          if (varlength != counter)
            sql += " or "
          end
          counter = counter + 1
        end
      end
      if (varlength >= 2)
        sql += ") "
      end
      find(:all, :conditions => [sql, "%#{province}%"], :order
=>
"name")
    end
  end
  def facility_attributes=(facility_attributes)
    facility_attributes.each do |attributes|
      if attributes[:id].blank?
        facilities.build(attributes)
      else
        facility = facilities.detect { |t| t.id =attributes[:id].to_i}
        facility.attributes = attributes
      end
    end
  end
  def save_facilities
    facilities.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def green_product_attributes=(green_product_attributes)
    green_product_attributes.each do |attributes|
      if attributes[:id].blank?
        green_products.build(attributes)
      else
        green_product = green_products.detect { |t| t.id =attributes[:id].to_i}
        green_product.attributes = attributes
      end
    end
  end
  def save_green_products
    green_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def discontinued_market_attributes=(discontinued_market_attributes)
    discontinued_market_attributes.each do |attributes|
      if attributes[:id].blank?
        discontinued_markets.build(attributes)
      else
        discontinued_market = discontinued_markets.detect { |t| t.id
== attributes[:id].to_i}
        discontinued_market.attributes = attributes
      end
    end
  end
  def save_discontinued_markets
    discontinued_markets.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  ############################################
  def
wood_based_building_system_product_attributes=(wood_based_building_system_product_attributes)
    wood_based_building_system_product_attributes.each do |attributes|
      if attributes[:id].blank?
        wood_based_building_system_products.build(attributes)
      else
        wood_based_building_system_product
wood_based_building_system_products.detect { |t| t.id =attributes[:id].to_i}
        wood_based_building_system_product.attributes = attributes
      end
    end
  end
  def save_wood_based_building_system_products
    wood_based_building_system_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def
non_wood_based_building_system_product_attributes=(non_wood_based_building_system_product_attributes)
    non_wood_based_building_system_product_attributes.each do |
attributes|
      if attributes[:id].blank?
        non_wood_based_building_system_products.build(attributes)
      else
        non_wood_based_building_system_product
non_wood_based_building_system_products.detect { |t| t.id =attributes[:id].to_i}
        non_wood_based_building_system_product.attributes = attributes
      end
    end
  end
  def save_non_wood_based_building_system_products
    non_wood_based_building_system_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def
wood_windows_doors_product_attributes=(wood_windows_doors_product_attributes)
    wood_windows_doors_product_attributes.each do |attributes|
      if attributes[:id].blank?
        wood_windows_doors_products.build(attributes)
      else
        wood_windows_doors_product wood_windows_doors_products.detect { |t| t.id
== attributes[:id].to_i}
        wood_windows_doors_product.attributes = attributes
      end
    end
  end
  def save_wood_windows_doors_products
    wood_windows_doors_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def
non_wood_windows_and_doors_product_attributes=(non_wood_windows_and_doors_product_attributes)
    non_wood_windows_and_doors_product_attributes.each do |attributes|
      if attributes[:id].blank?
        non_wood_windows_and_doors_products.build(attributes)
      else
        non_wood_windows_and_doors_product
non_wood_windows_and_doors_products.detect { |t| t.id =attributes[:id].to_i}
        non_wood_windows_and_doors_product.attributes = attributes
      end
    end
  end
  def save_non_wood_windows_and_doors_products
    non_wood_windows_and_doors_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def millwork_product_attributes=(millwork_product_attributes)
    millwork_product_attributes.each do |attributes|
      if attributes[:id].blank?
        millwork_products.build(attributes)
      else
        millwork_product = millwork_products.detect { |t| t.id
=attributes[:id].to_i}
        millwork_product.attributes = attributes
      end
    end
  end
  def save_millwork_products
    millwork_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def
wood_based_panel_product_attributes=(wood_based_panel_product_attributes)
    wood_based_panel_product_attributes.each do |attributes|
      if attributes[:id].blank?
        wood_based_panel_products.build(attributes)
      else
        wood_based_panel_product = wood_based_panel_products.detect { |
t| t.id == attributes[:id].to_i}
        wood_based_panel_product.attributes = attributes
      end
    end
  end
  def save_wood_based_panel_products
    wood_based_panel_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def flooring_product_attributes=(flooring_product_attributes)
    flooring_product_attributes.each do |attributes|
      if attributes[:id].blank?
        flooring_products.build(attributes)
      else
        flooring_product = flooring_products.detect { |t| t.id
=attributes[:id].to_i}
        flooring_product.attributes = attributes
      end
    end
  end
  def save_flooring_products
    flooring_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def
cabinetry_and_furniture_product_attributes=(cabinetry_and_furniture_product_attributes)
    cabinetry_and_furniture_product_attributes.each do |attributes|
      if attributes[:id].blank?
        cabinetry_and_furniture_products.build(attributes)
      else
        cabinetry_and_furniture_product cabinetry_and_furniture_products.detect
{ |t| t.id =attributes[:id].to_i}
        cabinetry_and_furniture_product.attributes = attributes
      end
    end
  end
  def save_cabinetry_and_furniture_products
    cabinetry_and_furniture_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def
outdoor_wood_based_product_attributes=(outdoor_wood_based_product_attributes)
    outdoor_wood_based_product_attributes.each do |attributes|
      if attributes[:id].blank?
        outdoor_wood_based_products.build(attributes)
      else
        outdoor_wood_based_product outdoor_wood_based_products.detect { |t| t.id
== attributes[:id].to_i}
        outdoor_wood_based_product.attributes = attributes
      end
    end
  end
  def save_outdoor_wood_based_products
    outdoor_wood_based_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def
outdoor_non_wood_based_product_attributes=(outdoor_non_wood_based_product_attributes)
    outdoor_non_wood_based_product_attributes.each do |attributes|
      if attributes[:id].blank?
        outdoor_non_wood_based_products.build(attributes)
      else
        outdoor_non_wood_based_product outdoor_non_wood_based_products.detect {
|t| t.id =attributes[:id].to_i}
        outdoor_non_wood_based_product.attributes = attributes
      end
    end
  end
  def save_outdoor_non_wood_based_products
    outdoor_non_wood_based_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def
other_wood_based_building_product_attributes=(other_wood_based_building_product_attributes)
    other_wood_based_building_product_attributes.each do |attributes|
      if attributes[:id].blank?
        other_wood_based_building_products.build(attributes)
      else
        other_wood_based_building_product
other_wood_based_building_products.detect { |t| t.id =attributes[:id].to_i}
        other_wood_based_building_product.attributes = attributes
      end
    end
  end
  def save_other_wood_based_building_products
    other_wood_based_building_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def
other_non_wood_based_building_product_attributes=(other_non_wood_based_building_product_attributes)
    other_non_wood_based_building_product_attributes.each do |
attributes|
      if attributes[:id].blank?
        other_non_wood_based_building_products.build(attributes)
      else
        other_non_wood_based_building_product
other_non_wood_based_building_products.detect { |t| t.id =attributes[:id].to_i}
        other_non_wood_based_building_product.attributes = attributes
      end
    end
  end
  def save_other_non_wood_based_building_products
    other_non_wood_based_building_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def
stone_processed_products_product_attributes=(stone_processed_products_product_attributes)
    stone_processed_products_product_attributes.each do |attributes|
      if attributes[:id].blank?
        stone_processed_products_products.build(attributes)
      else
        stone_processed_products_product
stone_processed_products_products.detect { |t| t.id =attributes[:id].to_i}
        stone_processed_products_product.attributes = attributes
      end
    end
  end
  def save_stone_processed_products_products
    stone_processed_products_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
  def insulation_product_attributes=(insulation_product_attributes)
    insulation_product_attributes.each do |attributes|
      if attributes[:id].blank?
        insulation_products.build(attributes)
      else
        insulation_product = insulation_products.detect { |t| t.id
=attributes[:id].to_i}
        insulation_product.attributes = attributes
      end
    end
  end
  def save_insulation_products
    insulation_products.each do |t|
      if t.should_destroy?
        t.destroy
      else
        t.save(false)
      end
    end
  end
end
On May 28, 2:00 pm, JDevine
<johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> By a "field and an association by the same name" I mean do you
have a
> field in your database table named
''outdoor_wood_based_products'' as
> well as an association in your model ("has_many",
> "has_and_belongs_to_many", etc) that is also called
> ''outdoor_wood_based_products''.
>
> In a console window (cmd if you''re on Windows, or terminal if
you''re
> on UNIX/Mac), navigate to your base Rails project directory (c:/
> myproject),
> and type "ruby script/console". That gives you an interactive
ruby
> session with all the same
> libraries loaded as your webserver would see. That way you can create
> objects, call methods etc interactively through ruby
> without going through the browser.
>
> Try that (it''s an indispensable tool as you''re
developing),
>
> Also paste in your Company.rb model so I can see what''s going on,
as
> well as the companies database schema definition.
>
> On May 28, 11:49 am, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > What do you mean by a "field and an association by the same
name"
>
> > I have a company table in my DB with a field called
> > outdoor_wood_based_products
>
> > not sure I have a script console. I am new to this as you can tell and
> > I am running Netbeans 6 with ruby as a plugin
>
> > On May 28, 1:41 pm, JDevine
<johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > Well without , obviously you''re outputting an
OutdoorWoodBasedProduct
> > > model somewhere repeatedly,
> > > or a collection of them -- my guess is <%=h
> > > company.outdoor_wood_based_products %>.
>
> > > If that really is 1 or 0, then I don''t know if I can
help.
>
> > > Do you have both a field and an association by the same name?
>
> > > If you go into script/console, what is the output for:
>
> > > Company.find(:first).outdoor_wood_based_products
>
> > > On May 28, 11:16 am, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > I am trying to test to see if it is a 1 and if so then to
display
> > > > details
>
> > > >   <%=h company.outdoor_wood_based_products %>
> > > >                           <%
if(company.outdoor_wood_based_products => > > > 1 ||
company.outdoor_non_wood_based_products == 1) %>
>
> > > > gives me the following:
>
> > > > #<OutdoorWoodBasedProduct:0x1b07392>
 #<OutdoorWoodBasedProduct:
> > > > 0x193973d>  #<OutdoorWoodBasedProduct:
> > > > 0x14346a4>#<OutdoorWoodBasedProduct:
> > > > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97>
> > > > #<OutdoorWoodBasedProduct:0x17d40b7>
 #<OutdoorWoodBasedProduct:
> > > > 0x1a52e8f>  #<OutdoorWoodBasedProduct:
> > > > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031>
> > > > #<OutdoorWoodBasedProduct:0x7272ca>
 #<OutdoorWoodBasedProduct:
> > > > 0x11e7bb1>  #<OutdoorWoodBasedProduct:0x58694a>
> > > > #<OutdoorWoodBasedProduct:0x10c6ab0>
 #<OutdoorWoodBasedProduct:
> > > > 0x1162955>  #<OutdoorWoodBasedProduct:0x31a99a>
> > > > #<OutdoorWoodBasedProduct:0x13ebb53>
 #<OutdoorWoodBasedProduct:
> > > > 0x1b45d04>
>
> > > > On May 28, 1:11 pm, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > > company.wood_based_products is a field in the database
that holds
> > > > > either a 1 or a 0.
>
> > > > > On May 28, 12:51 pm, JDevine
<johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > > > I''m guessing company.wood_based_products
is an object or array or
> > > > > > something other than a string?
>
> > > > > > If you see "#" on your page check the
page source and see if there''s
> > > > > > more there, like #<Company: id: 1223...>,
> > > > > > with everything in brackets hidden because
it''s treated as an xml tag.
>
> > > > > > If that''s the case it should help you
figure out what your problem is,
> > > > > > probably trying to
> > > > > > output something that isn''t a string.
>
> > > > > > On May 28, 10:00 am, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > > > > I am having problems trying to get the output
to work in an
> > > > > > > application I have. Here is the example
>
> > > > > > > THIS GIVES ME THE CORRECT VALUES
> > > > > > >  <!-- ######## Flooring ######### -->
> > > > > > >                   <% if(params[:flooring])
%>
> > > > > > >                     <tr><td
colspan="4"><h2>Flooring</h2></td></tr>
> > > > > > >                     <% for company in
@companies %>
> > > > > > >                           <%
if(company.flooring == 1)
> > > > > > > %>
> > > > > > >                         <tr>
> > > > > > >                           <td><%=
link_to  company.name, company %></
> > > > > > > td>
> > > > > > >                           <!--" +
image_tag(''view2.gif'', :border =>
> > > > > > > ''0'') + "-->
>
> > > > > > > <% if session[:user_id] %>
> > > > > > >                             <td><%=
link_to  "[old view]", :controller
> > > > > > > => "companies", :action=>
"show_org", :id => company.id %></td>
> > > > > > >                             <td><%=
link_to "[edit]",
> > > > > > > edit_company_path(company) %></td>
> > > > > > >                             <td><%=
link_to "[delete]",
> > > > > > > company, :confirm => ''Are you
sure?'', :method => :delete %></td>
> > > > > > >                           <% end %>
> > > > > > >                   <% end %>
> > > > > > >                       </tr>
> > > > > > >                     <% end %>
> > > > > > >                   <% end %>
>
> > > > > > > THIS GIVES ME "#" INSTEAD OF THE
CORRECT OUTPUT
> > > > > > > <!-- ######## Outdoor ######### -->
> > > > > > >                   <% if(params[:outdoor])
%>
> > > > > > >                     <tr><td
colspan="4"><h2>Outdoor</h2></td></tr>
> > > > > > >                     <% for company in
@companies %>
>
> > > > > > >                       <%=h
company.outdoor_wood_based_products %>
> > > > > > >                           <%
if(company.outdoor_wood_based_products => > > > > > > 1 ||
company.outdoor_non_wood_based_products == 1) %>
> > > > > > >                         <tr>
> > > > > > >                           <td><%=
link_to  company.name, company %></
> > > > > > > td>
> > > > > > >                           <!--" +
image_tag(''view2.gif'', :border =>
> > > > > > > ''0'') + "-->
> > > > > > >                             <% if
session[:user_id] %>
> > > > > > >                             <td><%=
link_to  "[old view]", :controller
> > > > > > > => "companies", :action=>
"show_org", :id => company.id %></td>
> > > > > > >                             <td><%=
link_to "[edit]",
> > > > > > > edit_company_path(company) %></td>
> > > > > > >                             <td><%=
link_to "[delete]",
> > > > > > > company, :confirm => ''Are you
sure?'', :method => :delete %></td>
> > > > > > >                           <% end %>
> > > > > > >                   <% end %>
> > > > > > >                       </tr>
> > > > > > >                     <% end %>
> > > > > > >                   <% end %>
>
> > > > > > > could it be something in a model or
controller
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Company Schema
 create_table "companies", :force => true do |t|
    t.string   "name"
    t.string   "contact"
    t.string   "title"
    t.string   "phy_add"
    t.string   "phy_post"
    t.string   "phy_city"
    t.string   "mail_add"
    t.string   "mail_post"
    t.string   "mail_city"
    t.string   "province"
    t.string   "phone"
    t.string   "fax"
    t.string   "url"
    t.string   "email"
    t.string   "owned_traded"
    t.string   "years_of_est"
    t.string   "employees"
    t.string   "perm_management"
    t.string   "perm_sales"
    t.string   "perm_trades"
    t.string   "total_per_capacity"
    t.string   "annual_sales"
    t.integer  "wood_based_building_systems"
    t.integer  "non_wood_based_building_system"
    t.integer  "wood_windows_and_doors"
    t.integer  "non_wood_windows_and_doors"
    t.integer  "millwork"
    t.integer  "wood_based_panels"
    t.integer  "flooring"
    t.integer  "cabinetry_and_furniture"
    t.integer  "outdoor_wood_based_products"
    t.integer  "outdoor_non_wood_based_products"
    t.integer  "other_wood_based_building_products"
    t.integer  "other_non_wood_based_building_products"
    t.integer  "stone_processed_products"
    t.integer  "insulation"
    t.integer  "focus_niche"
    t.integer  "focus_mass_volume"
    t.integer  "focus_comp_price"
    t.integer  "focus_high_quality"
    t.string   "annual_prod_green"
    t.text     "green_planning"
    t.string   "leed_cert"
    t.text     "leed_cert_exp"
    t.text     "specific_cert"
    t.string   "years_exp_out_canada"
    t.string   "total_annual_sales"
    t.integer  "inc_in_exp_sales"
    t.string   "inc_in_exp_sales_amnt"
    t.string   "current_export_local"
    t.text     "new_export_int"
    t.string   "prim_customer_a"
    t.integer  "discontinued_exporting"
    t.string   "prim_customer_b"
    t.string   "prim_customer_c"
    t.text     "dist_channels"
    t.integer  "has_business_plan"
    t.integer  "has_export_plan"
    t.integer  "has_commitment"
    t.integer  "does_access_market"
    t.integer  "does_identify_regulations"
    t.integer  "does_utilize_trade"
    t.integer  "does_trade_mission"
    t.integer  "does_trade_show"
    t.integer  "does_in_market_visit"
    t.integer  "does_other"
    t.text     "does_other_explain"
    t.integer  "hr_management"
    t.text     "hr_management_gap"
    t.integer  "hr_experience"
    t.text     "hr_experience_gap"
    t.integer  "hr_trades"
    t.text     "hr_trades_gap"
    t.integer  "hr_other_skills"
    t.text     "hr_other_skill_gap"
    t.integer  "pr_raw_materials"
    t.text     "pr_raw_materials_gap"
    t.integer  "pr_modification"
    t.text     "pr_modification_gap"
    t.integer  "pr_equip_tech"
    t.text     "pr_equip_tech_gap"
    t.integer  "pr_processes"
    t.text     "pr_processes_gap"
    t.integer  "pr_quality"
    t.text     "pr_quality_gap"
    t.integer  "pr_lic_cert"
    t.text     "pr_lic_cert_gap"
    t.integer  "pr_infrastructure"
    t.text     "pr_infrastructure_gap"
    t.integer  "or_adequate_fin"
    t.text     "or_adequate_fin_gap"
    t.integer  "or_pricing_str"
    t.text     "or_pricing_str_gap"
    t.integer  "or_deadlines"
    t.text     "or_deadlines_gap"
    t.integer  "or_website"
    t.text     "or_website_gap"
    t.integer  "or_material"
    t.text     "or_material_gap"
    t.integer  "partner_with_companies"
    t.text     "partner_with_companies_arr"
    t.text     "challenges"
    t.text     "beneficial"
    t.text     "assist_company_exporting"
    t.text     "company_desc"
    t.text     "additional_comments"
    t.datetime "created_at"
    t.datetime "updated_at"
  end
On May 28, 2:00 pm, JDevine
<johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> By a "field and an association by the same name" I mean do you
have a
> field in your database table named
''outdoor_wood_based_products'' as
> well as an association in your model ("has_many",
> "has_and_belongs_to_many", etc) that is also called
> ''outdoor_wood_based_products''.
>
> In a console window (cmd if you''re on Windows, or terminal if
you''re
> on UNIX/Mac), navigate to your base Rails project directory (c:/
> myproject),
> and type "ruby script/console". That gives you an interactive
ruby
> session with all the same
> libraries loaded as your webserver would see. That way you can create
> objects, call methods etc interactively through ruby
> without going through the browser.
>
> Try that (it''s an indispensable tool as you''re
developing),
>
> Also paste in your Company.rb model so I can see what''s going on,
as
> well as the companies database schema definition.
>
> On May 28, 11:49 am, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > What do you mean by a "field and an association by the same
name"
>
> > I have a company table in my DB with a field called
> > outdoor_wood_based_products
>
> > not sure I have a script console. I am new to this as you can tell and
> > I am running Netbeans 6 with ruby as a plugin
>
> > On May 28, 1:41 pm, JDevine
<johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > Well without , obviously you''re outputting an
OutdoorWoodBasedProduct
> > > model somewhere repeatedly,
> > > or a collection of them -- my guess is <%=h
> > > company.outdoor_wood_based_products %>.
>
> > > If that really is 1 or 0, then I don''t know if I can
help.
>
> > > Do you have both a field and an association by the same name?
>
> > > If you go into script/console, what is the output for:
>
> > > Company.find(:first).outdoor_wood_based_products
>
> > > On May 28, 11:16 am, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > I am trying to test to see if it is a 1 and if so then to
display
> > > > details
>
> > > >   <%=h company.outdoor_wood_based_products %>
> > > >                           <%
if(company.outdoor_wood_based_products => > > > 1 ||
company.outdoor_non_wood_based_products == 1) %>
>
> > > > gives me the following:
>
> > > > #<OutdoorWoodBasedProduct:0x1b07392>
 #<OutdoorWoodBasedProduct:
> > > > 0x193973d>  #<OutdoorWoodBasedProduct:
> > > > 0x14346a4>#<OutdoorWoodBasedProduct:
> > > > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97>
> > > > #<OutdoorWoodBasedProduct:0x17d40b7>
 #<OutdoorWoodBasedProduct:
> > > > 0x1a52e8f>  #<OutdoorWoodBasedProduct:
> > > > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031>
> > > > #<OutdoorWoodBasedProduct:0x7272ca>
 #<OutdoorWoodBasedProduct:
> > > > 0x11e7bb1>  #<OutdoorWoodBasedProduct:0x58694a>
> > > > #<OutdoorWoodBasedProduct:0x10c6ab0>
 #<OutdoorWoodBasedProduct:
> > > > 0x1162955>  #<OutdoorWoodBasedProduct:0x31a99a>
> > > > #<OutdoorWoodBasedProduct:0x13ebb53>
 #<OutdoorWoodBasedProduct:
> > > > 0x1b45d04>
>
> > > > On May 28, 1:11 pm, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > > company.wood_based_products is a field in the database
that holds
> > > > > either a 1 or a 0.
>
> > > > > On May 28, 12:51 pm, JDevine
<johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > > > I''m guessing company.wood_based_products
is an object or array or
> > > > > > something other than a string?
>
> > > > > > If you see "#" on your page check the
page source and see if there''s
> > > > > > more there, like #<Company: id: 1223...>,
> > > > > > with everything in brackets hidden because
it''s treated as an xml tag.
>
> > > > > > If that''s the case it should help you
figure out what your problem is,
> > > > > > probably trying to
> > > > > > output something that isn''t a string.
>
> > > > > > On May 28, 10:00 am, Shawn B
<sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > > > > I am having problems trying to get the output
to work in an
> > > > > > > application I have. Here is the example
>
> > > > > > > THIS GIVES ME THE CORRECT VALUES
> > > > > > >  <!-- ######## Flooring ######### -->
> > > > > > >                   <% if(params[:flooring])
%>
> > > > > > >                     <tr><td
colspan="4"><h2>Flooring</h2></td></tr>
> > > > > > >                     <% for company in
@companies %>
> > > > > > >                           <%
if(company.flooring == 1)
> > > > > > > %>
> > > > > > >                         <tr>
> > > > > > >                           <td><%=
link_to  company.name, company %></
> > > > > > > td>
> > > > > > >                           <!--" +
image_tag(''view2.gif'', :border =>
> > > > > > > ''0'') + "-->
>
> > > > > > > <% if session[:user_id] %>
> > > > > > >                             <td><%=
link_to  "[old view]", :controller
> > > > > > > => "companies", :action=>
"show_org", :id => company.id %></td>
> > > > > > >                             <td><%=
link_to "[edit]",
> > > > > > > edit_company_path(company) %></td>
> > > > > > >                             <td><%=
link_to "[delete]",
> > > > > > > company, :confirm => ''Are you
sure?'', :method => :delete %></td>
> > > > > > >                           <% end %>
> > > > > > >                   <% end %>
> > > > > > >                       </tr>
> > > > > > >                     <% end %>
> > > > > > >                   <% end %>
>
> > > > > > > THIS GIVES ME "#" INSTEAD OF THE
CORRECT OUTPUT
> > > > > > > <!-- ######## Outdoor ######### -->
> > > > > > >                   <% if(params[:outdoor])
%>
> > > > > > >                     <tr><td
colspan="4"><h2>Outdoor</h2></td></tr>
> > > > > > >                     <% for company in
@companies %>
>
> > > > > > >                       <%=h
company.outdoor_wood_based_products %>
> > > > > > >                           <%
if(company.outdoor_wood_based_products => > > > > > > 1 ||
company.outdoor_non_wood_based_products == 1) %>
> > > > > > >                         <tr>
> > > > > > >                           <td><%=
link_to  company.name, company %></
> > > > > > > td>
> > > > > > >                           <!--" +
image_tag(''view2.gif'', :border =>
> > > > > > > ''0'') + "-->
> > > > > > >                             <% if
session[:user_id] %>
> > > > > > >                             <td><%=
link_to  "[old view]", :controller
> > > > > > > => "companies", :action=>
"show_org", :id => company.id %></td>
> > > > > > >                             <td><%=
link_to "[edit]",
> > > > > > > edit_company_path(company) %></td>
> > > > > > >                             <td><%=
link_to "[delete]",
> > > > > > > company, :confirm => ''Are you
sure?'', :method => :delete %></td>
> > > > > > >                           <% end %>
> > > > > > >                   <% end %>
> > > > > > >                       </tr>
> > > > > > >                     <% end %>
> > > > > > >                   <% end %>
>
> > > > > > > could it be something in a model or
controller
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I don''t have a ruby directory in my application folder so I don''t think I can run the console On May 28, 2:00 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> By a "field and an association by the same name" I mean do you have a > field in your database table named ''outdoor_wood_based_products'' as > well as an association in your model ("has_many", > "has_and_belongs_to_many", etc) that is also called > ''outdoor_wood_based_products''. > > In a console window (cmd if you''re on Windows, or terminal if you''re > on UNIX/Mac), navigate to your base Rails project directory (c:/ > myproject), > and type "ruby script/console". That gives you an interactive ruby > session with all the same > libraries loaded as your webserver would see. That way you can create > objects, call methods etc interactively through ruby > without going through the browser. > > Try that (it''s an indispensable tool as you''re developing), > > Also paste in your Company.rb model so I can see what''s going on, as > well as the companies database schema definition. > > On May 28, 11:49 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > What do you mean by a "field and an association by the same name" > > > I have a company table in my DB with a field called > > outdoor_wood_based_products > > > not sure I have a script console. I am new to this as you can tell and > > I am running Netbeans 6 with ruby as a plugin > > > On May 28, 1:41 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Well without , obviously you''re outputting an OutdoorWoodBasedProduct > > > model somewhere repeatedly, > > > or a collection of them -- my guess is <%=h > > > company.outdoor_wood_based_products %>. > > > > If that really is 1 or 0, then I don''t know if I can help. > > > > Do you have both a field and an association by the same name? > > > > If you go into script/console, what is the output for: > > > > Company.find(:first).outdoor_wood_based_products > > > > On May 28, 11:16 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I am trying to test to see if it is a 1 and if so then to display > > > > details > > > > > <%=h company.outdoor_wood_based_products %> > > > > <% if(company.outdoor_wood_based_products => > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > gives me the following: > > > > > #<OutdoorWoodBasedProduct:0x1b07392> #<OutdoorWoodBasedProduct: > > > > 0x193973d> #<OutdoorWoodBasedProduct: > > > > 0x14346a4>#<OutdoorWoodBasedProduct: > > > > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97> > > > > #<OutdoorWoodBasedProduct:0x17d40b7> #<OutdoorWoodBasedProduct: > > > > 0x1a52e8f> #<OutdoorWoodBasedProduct: > > > > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031> > > > > #<OutdoorWoodBasedProduct:0x7272ca> #<OutdoorWoodBasedProduct: > > > > 0x11e7bb1> #<OutdoorWoodBasedProduct:0x58694a> > > > > #<OutdoorWoodBasedProduct:0x10c6ab0> #<OutdoorWoodBasedProduct: > > > > 0x1162955> #<OutdoorWoodBasedProduct:0x31a99a> > > > > #<OutdoorWoodBasedProduct:0x13ebb53> #<OutdoorWoodBasedProduct: > > > > 0x1b45d04> > > > > > On May 28, 1:11 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > company.wood_based_products is a field in the database that holds > > > > > either a 1 or a 0. > > > > > > On May 28, 12:51 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I''m guessing company.wood_based_products is an object or array or > > > > > > something other than a string? > > > > > > > If you see "#" on your page check the page source and see if there''s > > > > > > more there, like #<Company: id: 1223...>, > > > > > > with everything in brackets hidden because it''s treated as an xml tag. > > > > > > > If that''s the case it should help you figure out what your problem is, > > > > > > probably trying to > > > > > > output something that isn''t a string. > > > > > > > On May 28, 10:00 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > I am having problems trying to get the output to work in an > > > > > > > application I have. Here is the example > > > > > > > > THIS GIVES ME THE CORRECT VALUES > > > > > > > <!-- ######## Flooring ######### --> > > > > > > > <% if(params[:flooring]) %> > > > > > > > <tr><td colspan="4"><h2>Flooring</h2></td></tr> > > > > > > > <% for company in @companies %> > > > > > > > <% if(company.flooring == 1) > > > > > > > %> > > > > > > > <tr> > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > td> > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > ''0'') + "--> > > > > > > > > <% if session[:user_id] %> > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > <td><%= link_to "[edit]", > > > > > > > edit_company_path(company) %></td> > > > > > > > <td><%= link_to "[delete]", > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > <% end %> > > > > > > > <% end %> > > > > > > > </tr> > > > > > > > <% end %> > > > > > > > <% end %> > > > > > > > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT > > > > > > > <!-- ######## Outdoor ######### --> > > > > > > > <% if(params[:outdoor]) %> > > > > > > > <tr><td colspan="4"><h2>Outdoor</h2></td></tr> > > > > > > > <% for company in @companies %> > > > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > > > <% if(company.outdoor_wood_based_products => > > > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > > > <tr> > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > td> > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > ''0'') + "--> > > > > > > > <% if session[:user_id] %> > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > <td><%= link_to "[edit]", > > > > > > > edit_company_path(company) %></td> > > > > > > > <td><%= link_to "[delete]", > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > <% end %> > > > > > > > <% end %> > > > > > > > </tr> > > > > > > > <% end %> > > > > > > > <% end %> > > > > > > > > could it be something in a model or controller--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yup. You''ve defined a "has_many" association called "outdoor_wood_based_products" and you also have a database column by the same name. Can''t have both -- they do different things. You don''t need a ruby directory in your application directory. All you need is ruby to be in your execution path. I''d imaging NetBeans also has a "console" button, but I don''t have it in front of me. Anyway, that''s you''re problem. Calling two distinct things by the same name. On May 28, 12:07 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I don''t have a ruby directory in my application folder so I don''t > think I can run the console > > On May 28, 2:00 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > By a "field and an association by the same name" I mean do you have a > > field in your database table named ''outdoor_wood_based_products'' as > > well as an association in your model ("has_many", > > "has_and_belongs_to_many", etc) that is also called > > ''outdoor_wood_based_products''. > > > In a console window (cmd if you''re on Windows, or terminal if you''re > > on UNIX/Mac), navigate to your base Rails project directory (c:/ > > myproject), > > and type "ruby script/console". That gives you an interactive ruby > > session with all the same > > libraries loaded as your webserver would see. That way you can create > > objects, call methods etc interactively through ruby > > without going through the browser. > > > Try that (it''s an indispensable tool as you''re developing), > > > Also paste in your Company.rb model so I can see what''s going on, as > > well as the companies database schema definition. > > > On May 28, 11:49 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > What do you mean by a "field and an association by the same name" > > > > I have a company table in my DB with a field called > > > outdoor_wood_based_products > > > > not sure I have a script console. I am new to this as you can tell and > > > I am running Netbeans 6 with ruby as a plugin > > > > On May 28, 1:41 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Well without , obviously you''re outputting an OutdoorWoodBasedProduct > > > > model somewhere repeatedly, > > > > or a collection of them -- my guess is <%=h > > > > company.outdoor_wood_based_products %>. > > > > > If that really is 1 or 0, then I don''t know if I can help. > > > > > Do you have both a field and an association by the same name? > > > > > If you go into script/console, what is the output for: > > > > > Company.find(:first).outdoor_wood_based_products > > > > > On May 28, 11:16 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I am trying to test to see if it is a 1 and if so then to display > > > > > details > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > <% if(company.outdoor_wood_based_products => > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > > gives me the following: > > > > > > #<OutdoorWoodBasedProduct:0x1b07392> #<OutdoorWoodBasedProduct: > > > > > 0x193973d> #<OutdoorWoodBasedProduct: > > > > > 0x14346a4>#<OutdoorWoodBasedProduct: > > > > > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97> > > > > > #<OutdoorWoodBasedProduct:0x17d40b7> #<OutdoorWoodBasedProduct: > > > > > 0x1a52e8f> #<OutdoorWoodBasedProduct: > > > > > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031> > > > > > #<OutdoorWoodBasedProduct:0x7272ca> #<OutdoorWoodBasedProduct: > > > > > 0x11e7bb1> #<OutdoorWoodBasedProduct:0x58694a> > > > > > #<OutdoorWoodBasedProduct:0x10c6ab0> #<OutdoorWoodBasedProduct: > > > > > 0x1162955> #<OutdoorWoodBasedProduct:0x31a99a> > > > > > #<OutdoorWoodBasedProduct:0x13ebb53> #<OutdoorWoodBasedProduct: > > > > > 0x1b45d04> > > > > > > On May 28, 1:11 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > company.wood_based_products is a field in the database that holds > > > > > > either a 1 or a 0. > > > > > > > On May 28, 12:51 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > I''m guessing company.wood_based_products is an object or array or > > > > > > > something other than a string? > > > > > > > > If you see "#" on your page check the page source and see if there''s > > > > > > > more there, like #<Company: id: 1223...>, > > > > > > > with everything in brackets hidden because it''s treated as an xml tag. > > > > > > > > If that''s the case it should help you figure out what your problem is, > > > > > > > probably trying to > > > > > > > output something that isn''t a string. > > > > > > > > On May 28, 10:00 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > I am having problems trying to get the output to work in an > > > > > > > > application I have. Here is the example > > > > > > > > > THIS GIVES ME THE CORRECT VALUES > > > > > > > > <!-- ######## Flooring ######### --> > > > > > > > > <% if(params[:flooring]) %> > > > > > > > > <tr><td colspan="4"><h2>Flooring</h2></td></tr> > > > > > > > > <% for company in @companies %> > > > > > > > > <% if(company.flooring == 1) > > > > > > > > %> > > > > > > > > <tr> > > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > > td> > > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > > ''0'') + "--> > > > > > > > > > <% if session[:user_id] %> > > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > > <td><%= link_to "[edit]", > > > > > > > > edit_company_path(company) %></td> > > > > > > > > <td><%= link_to "[delete]", > > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > > <% end %> > > > > > > > > <% end %> > > > > > > > > </tr> > > > > > > > > <% end %> > > > > > > > > <% end %> > > > > > > > > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT > > > > > > > > <!-- ######## Outdoor ######### --> > > > > > > > > <% if(params[:outdoor]) %> > > > > > > > > <tr><td colspan="4"><h2>Outdoor</h2></td></tr> > > > > > > > > <% for company in @companies %> > > > > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > > > > <% if(company.outdoor_wood_based_products => > > > > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > > > > <tr> > > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > > td> > > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > > ''0'') + "--> > > > > > > > > <% if session[:user_id] %> > > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > > <td><%= link_to "[edit]", > > > > > > > > edit_company_path(company) %></td> > > > > > > > > <td><%= link_to "[delete]", > > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > > <% end %> > > > > > > > > <% end %> > > > > > > > > </tr> > > > > > > > > <% end %> > > > > > > > > <% end %> > > > > > > > > > could it be something in a model or controller--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Man I thank you a million. I spent the last 4 hours working on this I just tried you suggestion and it worked great. Thank you so much for spending the time with me. I am a newbie and having someone around like you is a life saver. It would be great to be able to contact you if I had any more questions. Would you mind. On May 28, 2:16 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yup. You''ve defined a "has_many" association called > "outdoor_wood_based_products" and you also have a database column by > the same name. Can''t have both -- they do different things. > > You don''t need a ruby directory in your application directory. All you > need is ruby to be in your execution path. I''d imaging NetBeans also > has a "console" button, but I don''t have it in front of me. > > Anyway, that''s you''re problem. Calling two distinct things by the same > name. > > On May 28, 12:07 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I don''t have a ruby directory in my application folder so I don''t > > think I can run the console > > > On May 28, 2:00 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > By a "field and an association by the same name" I mean do you have a > > > field in your database table named ''outdoor_wood_based_products'' as > > > well as an association in your model ("has_many", > > > "has_and_belongs_to_many", etc) that is also called > > > ''outdoor_wood_based_products''. > > > > In a console window (cmd if you''re on Windows, or terminal if you''re > > > on UNIX/Mac), navigate to your base Rails project directory (c:/ > > > myproject), > > > and type "ruby script/console". That gives you an interactive ruby > > > session with all the same > > > libraries loaded as your webserver would see. That way you can create > > > objects, call methods etc interactively through ruby > > > without going through the browser. > > > > Try that (it''s an indispensable tool as you''re developing), > > > > Also paste in your Company.rb model so I can see what''s going on, as > > > well as the companies database schema definition. > > > > On May 28, 11:49 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > What do you mean by a "field and an association by the same name" > > > > > I have a company table in my DB with a field called > > > > outdoor_wood_based_products > > > > > not sure I have a script console. I am new to this as you can tell and > > > > I am running Netbeans 6 with ruby as a plugin > > > > > On May 28, 1:41 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Well without , obviously you''re outputting an OutdoorWoodBasedProduct > > > > > model somewhere repeatedly, > > > > > or a collection of them -- my guess is <%=h > > > > > company.outdoor_wood_based_products %>. > > > > > > If that really is 1 or 0, then I don''t know if I can help. > > > > > > Do you have both a field and an association by the same name? > > > > > > If you go into script/console, what is the output for: > > > > > > Company.find(:first).outdoor_wood_based_products > > > > > > On May 28, 11:16 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I am trying to test to see if it is a 1 and if so then to display > > > > > > details > > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > > <% if(company.outdoor_wood_based_products => > > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > > > gives me the following: > > > > > > > #<OutdoorWoodBasedProduct:0x1b07392> #<OutdoorWoodBasedProduct: > > > > > > 0x193973d> #<OutdoorWoodBasedProduct: > > > > > > 0x14346a4>#<OutdoorWoodBasedProduct: > > > > > > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97> > > > > > > #<OutdoorWoodBasedProduct:0x17d40b7> #<OutdoorWoodBasedProduct: > > > > > > 0x1a52e8f> #<OutdoorWoodBasedProduct: > > > > > > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031> > > > > > > #<OutdoorWoodBasedProduct:0x7272ca> #<OutdoorWoodBasedProduct: > > > > > > 0x11e7bb1> #<OutdoorWoodBasedProduct:0x58694a> > > > > > > #<OutdoorWoodBasedProduct:0x10c6ab0> #<OutdoorWoodBasedProduct: > > > > > > 0x1162955> #<OutdoorWoodBasedProduct:0x31a99a> > > > > > > #<OutdoorWoodBasedProduct:0x13ebb53> #<OutdoorWoodBasedProduct: > > > > > > 0x1b45d04> > > > > > > > On May 28, 1:11 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > company.wood_based_products is a field in the database that holds > > > > > > > either a 1 or a 0. > > > > > > > > On May 28, 12:51 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > I''m guessing company.wood_based_products is an object or array or > > > > > > > > something other than a string? > > > > > > > > > If you see "#" on your page check the page source and see if there''s > > > > > > > > more there, like #<Company: id: 1223...>, > > > > > > > > with everything in brackets hidden because it''s treated as an xml tag. > > > > > > > > > If that''s the case it should help you figure out what your problem is, > > > > > > > > probably trying to > > > > > > > > output something that isn''t a string. > > > > > > > > > On May 28, 10:00 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > I am having problems trying to get the output to work in an > > > > > > > > > application I have. Here is the example > > > > > > > > > > THIS GIVES ME THE CORRECT VALUES > > > > > > > > > <!-- ######## Flooring ######### --> > > > > > > > > > <% if(params[:flooring]) %> > > > > > > > > > <tr><td colspan="4"><h2>Flooring</h2></td></tr> > > > > > > > > > <% for company in @companies %> > > > > > > > > > <% if(company.flooring == 1) > > > > > > > > > %> > > > > > > > > > <tr> > > > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > > > td> > > > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > > > ''0'') + "--> > > > > > > > > > > <% if session[:user_id] %> > > > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > > > <td><%= link_to "[edit]", > > > > > > > > > edit_company_path(company) %></td> > > > > > > > > > <td><%= link_to "[delete]", > > > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > > > <% end %> > > > > > > > > > <% end %> > > > > > > > > > </tr> > > > > > > > > > <% end %> > > > > > > > > > <% end %> > > > > > > > > > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT > > > > > > > > > <!-- ######## Outdoor ######### --> > > > > > > > > > <% if(params[:outdoor]) %> > > > > > > > > > <tr><td colspan="4"><h2>Outdoor</h2></td></tr> > > > > > > > > > <% for company in @companies %> > > > > > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > > > > > <% if(company.outdoor_wood_based_products => > > > > > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > > > > > <tr> > > > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > > > td> > > > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > > > ''0'') + "--> > > > > > > > > > <% if session[:user_id] %> > > > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > > > <td><%= link_to "[edit]", > > > > > > > > > edit_company_path(company) %></td> > > > > > > > > > <td><%= link_to "[delete]", > > > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > > > <% end %> > > > > > > > > > <% end %> > > > > > > > > > </tr> > > > > > > > > > <% end %> > > > > > > > > > <% end %> > > > > > > > > > > could it be something in a model or controller--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
No I don''t mind helping. What goes around comes around. Just so long as you make a reasonable attempt to figure it out on your own first :) On May 28, 12:23 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Man I thank you a million. I spent the last 4 hours working on this > > I just tried you suggestion and it worked great. Thank you so much for > spending the time with me. I am a newbie and having someone around > like you is a life saver. > > It would be great to be able to contact you if I had any more > questions. Would you mind. > > On May 28, 2:16 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Yup. You''ve defined a "has_many" association called > > "outdoor_wood_based_products" and you also have a database column by > > the same name. Can''t have both -- they do different things. > > > You don''t need a ruby directory in your application directory. All you > > need is ruby to be in your execution path. I''d imaging NetBeans also > > has a "console" button, but I don''t have it in front of me. > > > Anyway, that''s you''re problem. Calling two distinct things by the same > > name. > > > On May 28, 12:07 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I don''t have a ruby directory in my application folder so I don''t > > > think I can run the console > > > > On May 28, 2:00 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > By a "field and an association by the same name" I mean do you have a > > > > field in your database table named ''outdoor_wood_based_products'' as > > > > well as an association in your model ("has_many", > > > > "has_and_belongs_to_many", etc) that is also called > > > > ''outdoor_wood_based_products''. > > > > > In a console window (cmd if you''re on Windows, or terminal if you''re > > > > on UNIX/Mac), navigate to your base Rails project directory (c:/ > > > > myproject), > > > > and type "ruby script/console". That gives you an interactive ruby > > > > session with all the same > > > > libraries loaded as your webserver would see. That way you can create > > > > objects, call methods etc interactively through ruby > > > > without going through the browser. > > > > > Try that (it''s an indispensable tool as you''re developing), > > > > > Also paste in your Company.rb model so I can see what''s going on, as > > > > well as the companies database schema definition. > > > > > On May 28, 11:49 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > What do you mean by a "field and an association by the same name" > > > > > > I have a company table in my DB with a field called > > > > > outdoor_wood_based_products > > > > > > not sure I have a script console. I am new to this as you can tell and > > > > > I am running Netbeans 6 with ruby as a plugin > > > > > > On May 28, 1:41 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Well without , obviously you''re outputting an OutdoorWoodBasedProduct > > > > > > model somewhere repeatedly, > > > > > > or a collection of them -- my guess is <%=h > > > > > > company.outdoor_wood_based_products %>. > > > > > > > If that really is 1 or 0, then I don''t know if I can help. > > > > > > > Do you have both a field and an association by the same name? > > > > > > > If you go into script/console, what is the output for: > > > > > > > Company.find(:first).outdoor_wood_based_products > > > > > > > On May 28, 11:16 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > I am trying to test to see if it is a 1 and if so then to display > > > > > > > details > > > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > > > <% if(company.outdoor_wood_based_products => > > > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > > > > gives me the following: > > > > > > > > #<OutdoorWoodBasedProduct:0x1b07392> #<OutdoorWoodBasedProduct: > > > > > > > 0x193973d> #<OutdoorWoodBasedProduct: > > > > > > > 0x14346a4>#<OutdoorWoodBasedProduct: > > > > > > > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97> > > > > > > > #<OutdoorWoodBasedProduct:0x17d40b7> #<OutdoorWoodBasedProduct: > > > > > > > 0x1a52e8f> #<OutdoorWoodBasedProduct: > > > > > > > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031> > > > > > > > #<OutdoorWoodBasedProduct:0x7272ca> #<OutdoorWoodBasedProduct: > > > > > > > 0x11e7bb1> #<OutdoorWoodBasedProduct:0x58694a> > > > > > > > #<OutdoorWoodBasedProduct:0x10c6ab0> #<OutdoorWoodBasedProduct: > > > > > > > 0x1162955> #<OutdoorWoodBasedProduct:0x31a99a> > > > > > > > #<OutdoorWoodBasedProduct:0x13ebb53> #<OutdoorWoodBasedProduct: > > > > > > > 0x1b45d04> > > > > > > > > On May 28, 1:11 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > company.wood_based_products is a field in the database that holds > > > > > > > > either a 1 or a 0. > > > > > > > > > On May 28, 12:51 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > I''m guessing company.wood_based_products is an object or array or > > > > > > > > > something other than a string? > > > > > > > > > > If you see "#" on your page check the page source and see if there''s > > > > > > > > > more there, like #<Company: id: 1223...>, > > > > > > > > > with everything in brackets hidden because it''s treated as an xml tag. > > > > > > > > > > If that''s the case it should help you figure out what your problem is, > > > > > > > > > probably trying to > > > > > > > > > output something that isn''t a string. > > > > > > > > > > On May 28, 10:00 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > I am having problems trying to get the output to work in an > > > > > > > > > > application I have. Here is the example > > > > > > > > > > > THIS GIVES ME THE CORRECT VALUES > > > > > > > > > > <!-- ######## Flooring ######### --> > > > > > > > > > > <% if(params[:flooring]) %> > > > > > > > > > > <tr><td colspan="4"><h2>Flooring</h2></td></tr> > > > > > > > > > > <% for company in @companies %> > > > > > > > > > > <% if(company.flooring == 1) > > > > > > > > > > %> > > > > > > > > > > <tr> > > > > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > > > > td> > > > > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > > > > ''0'') + "--> > > > > > > > > > > > <% if session[:user_id] %> > > > > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > > > > <td><%= link_to "[edit]", > > > > > > > > > > edit_company_path(company) %></td> > > > > > > > > > > <td><%= link_to "[delete]", > > > > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > > > > <% end %> > > > > > > > > > > <% end %> > > > > > > > > > > </tr> > > > > > > > > > > <% end %> > > > > > > > > > > <% end %> > > > > > > > > > > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT > > > > > > > > > > <!-- ######## Outdoor ######### --> > > > > > > > > > > <% if(params[:outdoor]) %> > > > > > > > > > > <tr><td colspan="4"><h2>Outdoor</h2></td></tr> > > > > > > > > > > <% for company in @companies %> > > > > > > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > > > > > > <% if(company.outdoor_wood_based_products => > > > > > > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > > > > > > <tr> > > > > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > > > > td> > > > > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > > > > ''0'') + "--> > > > > > > > > > > <% if session[:user_id] %> > > > > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > > > > <td><%= link_to "[edit]", > > > > > > > > > > edit_company_path(company) %></td> > > > > > > > > > > <td><%= link_to "[delete]", > > > > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > > > > <% end %> > > > > > > > > > > <% end %> > > > > > > > > > > </tr> > > > > > > > > > > <% end %> > > > > > > > > > > <% end %> > > > > > > > > > > > could it be something in a model or controller--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
For sure, I respect that. Thanks again. On May 28, 2:25 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> No I don''t mind helping. What goes around comes around. Just so long > as you make a reasonable attempt to figure it out on your own first :) > > On May 28, 12:23 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Man I thank you a million. I spent the last 4 hours working on this > > > I just tried you suggestion and it worked great. Thank you so much for > > spending the time with me. I am a newbie and having someone around > > like you is a life saver. > > > It would be great to be able to contact you if I had any more > > questions. Would you mind. > > > On May 28, 2:16 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Yup. You''ve defined a "has_many" association called > > > "outdoor_wood_based_products" and you also have a database column by > > > the same name. Can''t have both -- they do different things. > > > > You don''t need a ruby directory in your application directory. All you > > > need is ruby to be in your execution path. I''d imaging NetBeans also > > > has a "console" button, but I don''t have it in front of me. > > > > Anyway, that''s you''re problem. Calling two distinct things by the same > > > name. > > > > On May 28, 12:07 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I don''t have a ruby directory in my application folder so I don''t > > > > think I can run the console > > > > > On May 28, 2:00 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > By a "field and an association by the same name" I mean do you have a > > > > > field in your database table named ''outdoor_wood_based_products'' as > > > > > well as an association in your model ("has_many", > > > > > "has_and_belongs_to_many", etc) that is also called > > > > > ''outdoor_wood_based_products''. > > > > > > In a console window (cmd if you''re on Windows, or terminal if you''re > > > > > on UNIX/Mac), navigate to your base Rails project directory (c:/ > > > > > myproject), > > > > > and type "ruby script/console". That gives you an interactive ruby > > > > > session with all the same > > > > > libraries loaded as your webserver would see. That way you can create > > > > > objects, call methods etc interactively through ruby > > > > > without going through the browser. > > > > > > Try that (it''s an indispensable tool as you''re developing), > > > > > > Also paste in your Company.rb model so I can see what''s going on, as > > > > > well as the companies database schema definition. > > > > > > On May 28, 11:49 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > What do you mean by a "field and an association by the same name" > > > > > > > I have a company table in my DB with a field called > > > > > > outdoor_wood_based_products > > > > > > > not sure I have a script console. I am new to this as you can tell and > > > > > > I am running Netbeans 6 with ruby as a plugin > > > > > > > On May 28, 1:41 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > Well without , obviously you''re outputting an OutdoorWoodBasedProduct > > > > > > > model somewhere repeatedly, > > > > > > > or a collection of them -- my guess is <%=h > > > > > > > company.outdoor_wood_based_products %>. > > > > > > > > If that really is 1 or 0, then I don''t know if I can help. > > > > > > > > Do you have both a field and an association by the same name? > > > > > > > > If you go into script/console, what is the output for: > > > > > > > > Company.find(:first).outdoor_wood_based_products > > > > > > > > On May 28, 11:16 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > I am trying to test to see if it is a 1 and if so then to display > > > > > > > > details > > > > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > > > > <% if(company.outdoor_wood_based_products => > > > > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > > > > > gives me the following: > > > > > > > > > #<OutdoorWoodBasedProduct:0x1b07392> #<OutdoorWoodBasedProduct: > > > > > > > > 0x193973d> #<OutdoorWoodBasedProduct: > > > > > > > > 0x14346a4>#<OutdoorWoodBasedProduct: > > > > > > > > 0x1d2dc82>#<OutdoorWoodBasedProduct:0x8afd97> > > > > > > > > #<OutdoorWoodBasedProduct:0x17d40b7> #<OutdoorWoodBasedProduct: > > > > > > > > 0x1a52e8f> #<OutdoorWoodBasedProduct: > > > > > > > > 0x36c862>#<OutdoorWoodBasedProduct:0x9da031> > > > > > > > > #<OutdoorWoodBasedProduct:0x7272ca> #<OutdoorWoodBasedProduct: > > > > > > > > 0x11e7bb1> #<OutdoorWoodBasedProduct:0x58694a> > > > > > > > > #<OutdoorWoodBasedProduct:0x10c6ab0> #<OutdoorWoodBasedProduct: > > > > > > > > 0x1162955> #<OutdoorWoodBasedProduct:0x31a99a> > > > > > > > > #<OutdoorWoodBasedProduct:0x13ebb53> #<OutdoorWoodBasedProduct: > > > > > > > > 0x1b45d04> > > > > > > > > > On May 28, 1:11 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > company.wood_based_products is a field in the database that holds > > > > > > > > > either a 1 or a 0. > > > > > > > > > > On May 28, 12:51 pm, JDevine <johnjdev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > I''m guessing company.wood_based_products is an object or array or > > > > > > > > > > something other than a string? > > > > > > > > > > > If you see "#" on your page check the page source and see if there''s > > > > > > > > > > more there, like #<Company: id: 1223...>, > > > > > > > > > > with everything in brackets hidden because it''s treated as an xml tag. > > > > > > > > > > > If that''s the case it should help you figure out what your problem is, > > > > > > > > > > probably trying to > > > > > > > > > > output something that isn''t a string. > > > > > > > > > > > On May 28, 10:00 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > > I am having problems trying to get the output to work in an > > > > > > > > > > > application I have. Here is the example > > > > > > > > > > > > THIS GIVES ME THE CORRECT VALUES > > > > > > > > > > > <!-- ######## Flooring ######### --> > > > > > > > > > > > <% if(params[:flooring]) %> > > > > > > > > > > > <tr><td colspan="4"><h2>Flooring</h2></td></tr> > > > > > > > > > > > <% for company in @companies %> > > > > > > > > > > > <% if(company.flooring == 1) > > > > > > > > > > > %> > > > > > > > > > > > <tr> > > > > > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > > > > > td> > > > > > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > > > > > ''0'') + "--> > > > > > > > > > > > > <% if session[:user_id] %> > > > > > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > > > > > <td><%= link_to "[edit]", > > > > > > > > > > > edit_company_path(company) %></td> > > > > > > > > > > > <td><%= link_to "[delete]", > > > > > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > > > > > <% end %> > > > > > > > > > > > <% end %> > > > > > > > > > > > </tr> > > > > > > > > > > > <% end %> > > > > > > > > > > > <% end %> > > > > > > > > > > > > THIS GIVES ME "#" INSTEAD OF THE CORRECT OUTPUT > > > > > > > > > > > <!-- ######## Outdoor ######### --> > > > > > > > > > > > <% if(params[:outdoor]) %> > > > > > > > > > > > <tr><td colspan="4"><h2>Outdoor</h2></td></tr> > > > > > > > > > > > <% for company in @companies %> > > > > > > > > > > > > <%=h company.outdoor_wood_based_products %> > > > > > > > > > > > <% if(company.outdoor_wood_based_products => > > > > > > > > > > 1 || company.outdoor_non_wood_based_products == 1) %> > > > > > > > > > > > <tr> > > > > > > > > > > > <td><%= link_to company.name, company %></ > > > > > > > > > > > td> > > > > > > > > > > > <!--" + image_tag(''view2.gif'', :border => > > > > > > > > > > > ''0'') + "--> > > > > > > > > > > > <% if session[:user_id] %> > > > > > > > > > > > <td><%= link_to "[old view]", :controller > > > > > > > > > > > => "companies", :action=> "show_org", :id => company.id %></td> > > > > > > > > > > > <td><%= link_to "[edit]", > > > > > > > > > > > edit_company_path(company) %></td> > > > > > > > > > > > <td><%= link_to "[delete]", > > > > > > > > > > > company, :confirm => ''Are you sure?'', :method => :delete %></td> > > > > > > > > > > > <% end %> > > > > > > > > > > > <% end %> > > > > > > > > > > > </tr> > > > > > > > > > > > <% end %> > > > > > > > > > > > <% end %> > > > > > > > > > > > > could it be something in a model or controller--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---