For my implementation I would like any user who is logged in to be able to add a school (object.) However, I would like this school to only become visible to that and all other users, including non-users if four other people have tried to add that school with the exact same school name. In this way, I hope that it will keep school names legitimate and clean. I can think of some implementations of how to do this. But I''m wondering what''s the best, and simplest way to do this? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
perhaps something as simple as: @school = School.find_by_name(params[:school][:name]) @school ||= School.create(:name => params[:school][:name], :other_field => params[:school][:other]) @school.increment!(:verified_by) On Dec 10, 2007 11:13 AM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > For my implementation I would like any user who is logged in to be able > to add a school (object.) However, I would like this school to only > become visible to that and all other users, including non-users if four > other people have tried to add that school with the exact same school > name. In this way, I hope that it will keep school names legitimate and > clean. > > I can think of some implementations of how to do this. But I''m wondering > what''s the best, and simplest way to do this? > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 sorry could you explain your code some more?> perhaps something as simple as: > > @school = School.find_by_name(params[:school][:name]) > @school ||= School.create(:name => params[:school][:name], :other_field > => > params[:school][:other]) > @school.increment!(:verified_by)-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
The code will either find a school if there is a school in the database which matches params[:school][:name] or return nil if there is not a school that has that name. If it happens to be nil, then it will create a school object with that name. :other_field is just a placeholder for any other fields you want to put in to the school record. Then because by now it should have a school object, it increments the column called "verified_by" by one. On Dec 10, 2007 1:07 PM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I''m sorry could you explain your code some more? > > > > perhaps something as simple as: > > > > @school = School.find_by_name(params[:school][:name]) > > @school ||= School.create(:name => params[:school][:name], :other_field > > => > > params[:school][:other]) > > @school.increment!(:verified_by) > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
OK. This works great. But can I add a twist? The school includes a column for user_id, so when searching for a school the code @school = School.find_by_title([:school][:title]) will not work as it will return an array. In addition, any user that has contributed to making the verified increment cannot add the school again, thus cheating the system of only unique users. Please advise, thank you. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 don''t see how School.find_by_title would return an array, unless you''ve customised the method. As for saving who has verified and who hasn''t maybe it might be easy to serialize an array into the schools table. Add serialize :verified_by into your model and then you should be able to write to this field as if it were an array. This has changed from my previous suggestion of incrementing a field with the same name. @school = School.find_by_title(params[:school][:title]) @school ||= School.create(params[:school].merge({:verified_by => "--- []"}) @school.verified_by << current_user unless @school.verified_by.include? (current_user) @school.save! On Dec 10, 2007 3:30 PM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > OK. This works great. But can I add a twist? > The school includes a column for user_id, so when searching for a school > the code > > @school = School.find_by_title([:school][:title]) > > will not work as it will return an array. In addition, any user that has > contributed to making the verified increment cannot add the school > again, thus cheating the system of only unique users. Please advise, > thank you. > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The --- [] is setting the default value (an empty array) of the verified_by field. If that wasn''t done then you would get an error because you would be effectively calling << on nil. On Dec 10, 2007 4:00 PM, Ryan Bigg <radarlistener-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I don''t see how School.find_by_title would return an array, unless you''ve > customised the method. > > As for saving who has verified and who hasn''t maybe it might be easy to > serialize an array into the schools table. > > Add serialize :verified_by into your model and then you should be able to > write to this field as if it were an array. This has changed from my > previous suggestion of incrementing a field with the same name. > > @school = School.find_by_title(params[:school][:title]) > @school ||= School.create(params[:school].merge({:verified_by => "--- > []"}) > @school.verified_by << current_user unless @school.verified_by.include?(current_user) > @school.save! > > > On Dec 10, 2007 3:30 PM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > > > OK. This works great. But can I add a twist? > > The school includes a column for user_id, so when searching for a school > > the code > > > > @school = School.find_by_title([:school][:title]) > > > > will not work as it will return an array. In addition, any user that has > > > > contributed to making the verified increment cannot add the school > > again, thus cheating the system of only unique users. Please advise, > > thank you. > > -- > > Posted via http://www.ruby-forum.com/. > > > > > > > > > > > -- > Ryan Bigg > http://www.frozenplague.net >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It says undefined method `include?'' for 0:Fixnum Hmmm... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
Assuming you''ve used migrations. The column should be a string and the default should be "--- []". No reason for it to give you a 0 number unless you set the field as an integer. On Dec 10, 2007 4:21 PM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > It says undefined method `include?'' for 0:Fixnum Hmmm... > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This implementation has lost its ability to increment up depending on if the user has not already incremented that particular school. In addition I keep getting that error. How do I know the field has turned into an array? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
Remove the field and re add it. Having it as an integer will not work! Re-add it as a string with the default of "--- []" If you read through one of my previous emails I mentioned that verified_by is no longer being incremented. *VERIFIED BY SHOULD NO LONGER BE INCREMENTED! * Verified by is now kept as a serialized array in the database. On Dec 10, 2007 4:33 PM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > This implementation has lost its ability to increment up depending on if > the user has not already incremented that particular school. In addition > I keep getting that error. How do I know the field has turned into an > array? > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
class School < ActiveRecord::Base has_many :courses has_many :works acts_as_rated :no_rater => true serialize :user_id end def create @school = School.find_by_title(params[:school][:title]) @school ||= School.create(params[:school].merge({ :user_id => "--- []" })) @school.user_id << current_user unless @school.user_id.include?(current_user) @school.save! redirect_to schools_path end t.string :user_id, :default => "--- []" all equals a no go for storing the users user_id in the array column -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
Is it still giving the Fixnum error? On Dec 10, 2007 4:39 PM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > class School < ActiveRecord::Base > has_many :courses > has_many :works > acts_as_rated :no_rater => true > serialize :user_id > end > > def create > @school = School.find_by_title(params[:school][:title]) > @school ||= School.create(params[:school].merge({ :user_id => "--- > []" })) > @school.user_id << current_user unless > @school.user_id.include?(current_user) > @school.save! > > redirect_to schools_path > end > > t.string :user_id, :default => "--- []" > > > all equals a no go for storing the users user_id in the array column > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
no error. only no functionality. the column just says --- when i query with mysql -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
Aha! Don''t query it with MySQL. Go into script/console and try @school = School.find(:first) @school.user_id And tell me what you get back I also recommend changing user_id to user_ids to signify that it holds more than one, but it''s just a cosmetic change. On Dec 10, 2007 4:45 PM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > no error. only no functionality. the column just says --- when i query > with mysql > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
That works great. You are so much help thank you. Any clues why this code is not working? for id in @school.user_ids if current_user != id @school.increment!(:verified_count) break end end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
current_user is a user object, id is a number. Try current_user.id On Dec 10, 2007 5:20 PM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > That works great. You are so much help thank you. Any clues why this > code is not working? > > for id in @school.user_ids > if current_user != id > @school.increment!(:verified_count) > break > end > end > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Still increments with .id appended. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
Ellis Berner wrote:> Still increments with .id appended.>> @school.user_ids=> [#<YAML::Object:0x174ef18 @ivars={"attributes"=>{"salt"=>"fe4249ff4cd74653efd009291740566cbde432ee", "updated_at"=>"2007-12-10 01:33:22", "crypted_password"=>"ae0a7781810a57d56a2cb4e33c18f5b6d64da703", "remember_token_expires_at"=>nil, "id"=>"1", "remember_token"=>nil}}, @class="User">] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
My fault! @school.verified_by << current_user Should be current_user.id On Dec 10, 2007 5:28 PM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Ellis Berner wrote: > > Still increments with .id appended. > > >> @school.user_ids > => [#<YAML::Object:0x174ef18 > @ivars={"attributes"=>{"salt"=>"fe4249ff4cd74653efd009291740566cbde432ee", > "updated_at"=>"2007-12-10 01:33:22", > "crypted_password"=>"ae0a7781810a57d56a2cb4e33c18f5b6d64da703", > "remember_token_expires_at"=>nil, "id"=>"1", "remember_token"=>nil}}, > @class="User">] > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hello again, I am terrible with MySQL thanks to Rails, but here is an instance to get the top_rated schools def find_top_rated(limit=nil) rating_class = acts_as_rated_options[:rating_class].constantize base_sql = <<-EOS select #{table_name}.*,COALESCE(average,0) AS rating_average from #{table_name} left outer join (select avg(rating) as average, rated_id from #{rating_class.table_name} WHERE AND rated_type = ''#{class_name}'' group by rated_id) as rated on rated_id=id order by rating_average DESC EOS base_sql += " LIMIT #{limit}" if limit find_by_sql base_sql end How is it that I can add WHERE (verified > 5) so that I can restrict what gets put in the array? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 should mention putting ...WHERE (verified > 5)... as it is in the statement already returns an error about there being no verified column. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
Try schools.verified > 5 instead. On Dec 11, 2007 2:39 AM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I should mention putting ...WHERE (verified > 5)... as it is in the > statement already returns an error about there being no verified column. > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mysql::Error: Unknown column ''schools.verified'' in ''where clause'': select schools.*,COALESCE(average,0) AS rating_average from schools left outer join (select avg(rating) as average, rated_id from ratings where schools.verified > 5 AND rated_type = ''School'' group by rated_id) as rated on rated_id=id order by rating_average DESC LIMIT 3 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
Isn''t it verified_by? And because it''s serialised you''ll need to use something else other than a WHERE MySQL call. On Dec 11, 2007 9:54 AM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Mysql::Error: Unknown column ''schools.verified'' in ''where clause'': > select schools.*,COALESCE(average,0) AS rating_average from schools left > outer join > (select avg(rating) as average, rated_id > from ratings > where schools.verified > 5 AND rated_type = ''School'' > group by rated_id) as rated > on rated_id=id > order by rating_average DESC > LIMIT 3 > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nope I use the column verified to track the integer count of how many unique users (from my serialized user_ids field) have verified a school. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/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 -~----------~----~----~----~------~----~------~--~---
Ah, good idea. Does that sql_query return schools as an array? Perhaps it would be easier to do a #select call on the returned array? On Dec 11, 2007 10:25 AM, Ellis Berner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Nope I use the column verified to track the integer count of how many > unique users (from my serialized user_ids field) have verified a school. > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---