I have this in my controller... @tech_standards = TechStandard.find_by_sql("SELECT * FROM tech_standards WHERE subpoint <> 0") Everything is fine except when I look at my view I still get supoints that are 0. When I run this query in my query browser I don''t. View: <select name="resource[tech_standard]" id="tech_standard"> <option value="0" selected="selected"></option> <% for @tech_standard in @tech_standards %> <option value="<%= @tech_standard.id %>"><%"#{@tech_standard.category} #{@tech_standard.point}.#{@tech_standard.subpoint }" %></option> <% end %> </select> Am I missing something? Seth Buntin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060217/664ffd71/attachment-0001.html
Have you tried inputting this exact string using mysql utility? Are you sure of your syntax? Check ''development.log'' under /log, and you can watch the query go by, and make sure it is doing exactly what you specified. I''d start with the mysql utility and see what data you get back first. - Nic. On 2/17/06, Buntin, Seth - KATE <Seth.Buntin@coe.murraystate.edu> wrote:> > > > I have this in my controller? > > > > @tech_standards = TechStandard.find_by_sql("SELECT * FROM tech_standards > WHERE subpoint <> 0") > > > > Everything is fine except when I look at my view I still get supoints that > are 0. When I run this query in my query browser I don''t. > > > > View: > > <select name="resource[tech_standard]" id="tech_standard"> > > <option value="0" selected="selected"></option> > > <% for @tech_standard in @tech_standards %> > > <option value="<%= @tech_standard.id %>"><%> "#{@tech_standard.category} > #{@tech_standard.point}.#{@tech_standard.subpoint }" %></option> > > <% end %> > > </select> > > > > Am I missing something? > > > > Seth Buntin > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- - Nic
Okay. So I might see the issue. Looking in the development.log file I see: [4;35;1mTechStandard Load (0.015000) SELECT * FROM tech_standards WHERE subpoint <> 0 Then I see: [4;36;1mTechStandard Columns (0.000000) [0;1mSHOW FIELDS FROM tech_standards Is that the problem? -----Original Message----- From: Nic Werner [mailto:nicwerner@gmail.com] Sent: Friday, February 17, 2006 11:02 AM To: rails@lists.rubyonrails.org Subject: Re: [Rails] Why doesn''t this work! Have you tried inputting this exact string using mysql utility? Are you sure of your syntax? Check ''development.log'' under /log, and you can watch the query go by, and make sure it is doing exactly what you specified. I''d start with the mysql utility and see what data you get back first. - Nic. On 2/17/06, Buntin, Seth - KATE <Seth.Buntin@coe.murraystate.edu> wrote:> > > > I have this in my controller... > > > > @tech_standards = TechStandard.find_by_sql("SELECT * FROMtech_standards> WHERE subpoint <> 0") > > > > Everything is fine except when I look at my view I still get supointsthat> are 0. When I run this query in my query browser I don''t. > > > > View: > > <select name="resource[tech_standard]" id="tech_standard"> > > <option value="0" selected="selected"></option> > > <% for @tech_standard in @tech_standards %> > > <option value="<%= @tech_standard.id %>"><%> "#{@tech_standard.category} > #{@tech_standard.point}.#{@tech_standard.subpoint }" %></option> > > <% end %> > > </select> > > > > Am I missing something? > > > > Seth Buntin > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- - Nic
The SHOW FIELDS is just Rails getting the names of the columns, try that in your MySQL client and you''ll see. Your log is displaying in ANSI colors, which is why it looks a little off. You can disable that with: ActiveRecord::Base.colorize_logging = false But why don''t you cut and paste that select statement into a MySQL client and see what you get back? Are you sure this command works as you''d like? On 2/17/06, Buntin, Seth - KATE <Seth.Buntin@coe.murraystate.edu> wrote:> Okay. So I might see the issue. > > Looking in the development.log file I see: > > [4;35;1mTechStandard Load (0.015000) SELECT * FROM > tech_standards WHERE subpoint <> 0 > > Then I see: > > [4;36;1mTechStandard Columns (0.000000) [0;1mSHOW FIELDS FROM > tech_standards > > Is that the problem? > > -----Original Message----- > From: Nic Werner [mailto:nicwerner@gmail.com] > Sent: Friday, February 17, 2006 11:02 AM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] Why doesn''t this work! > > Have you tried inputting this exact string using mysql utility? Are > you sure of your syntax? > > Check ''development.log'' under /log, and you can watch the query go by, > and make sure it is doing exactly what you specified. > > I''d start with the mysql utility and see what data you get back first. > > - Nic. > > On 2/17/06, Buntin, Seth - KATE <Seth.Buntin@coe.murraystate.edu> wrote: > > > > > > > > I have this in my controller... > > > > > > > > @tech_standards = TechStandard.find_by_sql("SELECT * FROM > tech_standards > > WHERE subpoint <> 0") > > > > > > > > Everything is fine except when I look at my view I still get supoints > that > > are 0. When I run this query in my query browser I don''t. > > > > > > > > View: > > > > <select name="resource[tech_standard]" id="tech_standard"> > > > > <option value="0" selected="selected"></option> > > > > <% for @tech_standard in @tech_standards %> > > > > <option value="<%= @tech_standard.id %>"><%> > "#{@tech_standard.category} > > #{@tech_standard.point}.#{@tech_standard.subpoint }" %></option> > > > > <% end %> > > > > </select> > > > > > > > > Am I missing something? > > > > > > > > Seth Buntin > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > - Nic > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- - Nic
I did the cut and paste thing before I first posted to the list and it worked fine. I don''t know what to do; it still works in my query browser. -----Original Message----- From: Nic Werner [mailto:nicwerner@gmail.com] Sent: Friday, February 17, 2006 12:07 PM To: rails@lists.rubyonrails.org Subject: Re: [Rails] Why doesn''t this work! The SHOW FIELDS is just Rails getting the names of the columns, try that in your MySQL client and you''ll see. Your log is displaying in ANSI colors, which is why it looks a little off. You can disable that with: ActiveRecord::Base.colorize_logging = false But why don''t you cut and paste that select statement into a MySQL client and see what you get back? Are you sure this command works as you''d like? On 2/17/06, Buntin, Seth - KATE <Seth.Buntin@coe.murraystate.edu> wrote:> Okay. So I might see the issue. > > Looking in the development.log file I see: > > [4;35;1mTechStandard Load (0.015000) SELECT * FROM > tech_standards WHERE subpoint <> 0 > > Then I see: > > [4;36;1mTechStandard Columns (0.000000) [0;1mSHOW FIELDS FROM > tech_standards > > Is that the problem? > > -----Original Message----- > From: Nic Werner [mailto:nicwerner@gmail.com] > Sent: Friday, February 17, 2006 11:02 AM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] Why doesn''t this work! > > Have you tried inputting this exact string using mysql utility? Are > you sure of your syntax? > > Check ''development.log'' under /log, and you can watch the query go by, > and make sure it is doing exactly what you specified. > > I''d start with the mysql utility and see what data you get back first. > > - Nic. > > On 2/17/06, Buntin, Seth - KATE <Seth.Buntin@coe.murraystate.edu>wrote:> > > > > > > > I have this in my controller... > > > > > > > > @tech_standards = TechStandard.find_by_sql("SELECT * FROM > tech_standards > > WHERE subpoint <> 0") > > > > > > > > Everything is fine except when I look at my view I still getsupoints> that > > are 0. When I run this query in my query browser I don''t. > > > > > > > > View: > > > > <select name="resource[tech_standard]" id="tech_standard"> > > > > <option value="0" selected="selected"></option> > > > > <% for @tech_standard in @tech_standards %> > > > > <option value="<%= @tech_standard.id %>"><%> > "#{@tech_standard.category} > > #{@tech_standard.point}.#{@tech_standard.subpoint }" %></option> > > > > <% end %> > > > > </select> > > > > > > > > Am I missing something? > > > > > > > > Seth Buntin > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > - Nic > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- - Nic