search for: school_id

Displaying 18 results from an estimated 18 matches for "school_id".

2006 Jul 31
2
Updating a belongs_to foreign key leaves the old association object available
Perhaps this is intentional, but it seems unlikely: class Person < ActiveRecord::Base belongs_to :school end p = Person.find(:first) p.school # nil p.school_id = School.find_by_name(''High School'').id p.school.name # High School p.school_id = School.find_by_name(''Primary School'').id p.school.name # High School <= Shouldn''t this be Primary School? p.school.id == p.school_id # false !!! Of course, p.school(:re...
2008 May 25
2
record will absolutely not save! so weird, please help.
...of sudden, records for a certain model will not save with #save Please take a look at this: >> p = Payment.new(:payment_reason_id => 1, :payment_method_id => 1, :date => Date.today, :amount => ''5.00'', :payable => Student.find(608)) => #<Payment id: nil, school_id: nil, payment_reason_id: 1, payment_method_id: 1, date: "2008-05-25", amount: #<BigDecimal: 46958f8,''0.5E1'',4(8)>, created_at: nil, updated_at: nil, invoice_id: nil, creator: nil, check_number: nil, payable_type: "Student", payable_id: 608> >> p....
2007 Jul 21
2
avoiding timconsuming for loop renaming identifiers
Hi All I was wondering if I can avoid a time-consuming for loop on my 600000 obs dataset. school_id y 8 9.87 8 8.89 8 7.89 8 8.88 20 6.78 20 9.99 20 8.79 31 10.1 31 11 There are, say, 143 different schools in this 600000 obs dataset. I need to thave sequential identifiers, 1,2,3,4,5,...,143. I was using an a...
2007 May 28
5
validates_uniqueness_of does not pass unit test
I am doing some very very basic unit testing. If I take away the uniqueness validation, the tests pass. Could this be a bug in Edge Rails? --~--~---------~--~----~------------~-------~--~----~ 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
2006 Jul 27
0
Controllers, Models, and Validations...
...erships If a user leaves a school or a group, the status is just reset to 0. I am having a bit of a dilemma, however. When a user joins a group (creates an enrollment), there are several things that need to be checked: 1. We need a valid user id 2. We need a valid group id 3. The group''s school_id must be the same as the user''s currently active enrollment school_id (there is only one enrollment active at a time) 4. You can''t join a group you already belong to (in other words, create duplicate memberships) Logically, this should go in the Membership model, right? I had put...
2006 Feb 11
2
Migrations and Unintialized Constants Error
...t.column :covered, :string t.column :content, :text t.column :created_at, :datetime t.column :updated_at, :datetime end Note.create_versioned_table The same thing happens with: create_table :faculties do |t| t.column :id, :integer t.column :school_id, :integer t.column :name, :string t.column :created_at, :datetime t.column :updated_at, :datetime end Faculty.create :school_id => 1, :name => "Faculty of Engineering and Computer Science" Anyone can give me some insight into my problem please :-)...
2008 Apr 07
5
Associations errors
undefined method `each'' for 0:Fixnum at line @school = School.find_by_title(params[:school_id].gsub(''-'', " ")) for team in @school.teams ........ end @school does exist cause i tried with .find(:first) and it gave the same error. Also I''m getting undefined method `reject'' for #<Game:0x24ca1c4> From @home.game_ids = @game @game =...
2006 Jun 03
8
confused about ActiveRecord relationships
I am very confused about where to put the belongs_to and the has_one (and other relationship identifiers). I have read the RDoc and the agile book many times about this and I think i still see it backwards. Let me outline my app so you have an understanding... I have 2 tables: Schools { id, school_name, address_id } and Addresses { street1, street2, city, state, zip, country } *** this
2006 Mar 27
1
Best way about doing this?
...a stupid question, but I can''t see it. Can you do a loop through each of the classrooms and assign them an array of teachers? here is the controller for the form so far: def view_school @school = School.find(params[:id]) @classrooms = Classroom.find(:all, :conditions => ["school_id = ?", params[:id]) end -- Posted via http://www.ruby-forum.com/.
2009 Feb 12
4
routes
I''m trying to figure this. in my schools controller i want to do this.... # implement a create action to create just the review for the School... def create_review_for_a_school @review = Review.new @school = School.find(params[:school_id]) @review = @school.reviews.build(params[:review]) if @review.save # The creation worked....do this flash[:notice] = ''Review was successfully updated.'' format.html { redirect_to(@school) } # format.xml { head :ok } else # if it didnt save do th...
2008 Apr 11
2
Validating an ActiveRecord object and its has_many :through associations
...one twice, once from eca''s and again from classes. i would like to handle this through a validates_associated so that the Student is validated whenever an association is changed or added. However, I can''t see how this would work. To illustrate: >>ss = StudentsSchool.new(:school_id => 1, :student_id => 10) => #<StudentsSchooll>... >>ss.student => #<Student>... >>ss.student.students_school => [] So the ss is still a temporary object that won''t be seen in the Student validation. Can anyone share some ideas? --~--~---------~--~--...
2009 Feb 09
3
rendering original view
def create # next statement is original and is removed # @review = Review.new(params[:review]) @school = School.find(params[:school_id]) # @review = @school.reviews.create!(params[:review]) @review = @school.reviews.build(params[:review]) respond_to do |format| if @review.save flash[:notice] = ''Review was successfully created.'' # format.html { redirect_to(@review) } fo...
2008 Apr 07
7
Saving attribute
Something is getting lost here. def create @home = Team.find_by_user_id(current_user.id) for player in @home.players player.update_attribute(:game_id, @game.id) end end def show @players = Player.find_all_by_game_id(params[:id]) end view <%= @players.size %> # mistakenly equals zero Played with the console and everything should be working fine...
2011 Mar 01
0
Association data within a fields_for
How do I use association data from within a fields_for? I''ve got a has many through relationship between users, schools and schools_users. A user can have multiple schools and a school has multiple users. In schools_users there is a user_role field in addition to the common user_id and school_id. In the show view I have: <% @school.schools_users.each do |user| %> <tr><td><%= user.user.first_name %> <%= user.user.last_name %></td><td><%= user.user_role %></td></tr> <% end %> but I can''t figure out how to do the s...
2006 Aug 02
1
ActiveRecord: find_or_create with has_and_belongs_to_many --
...ms.find_or_create_by_code("FALL06") the queries in the log show the expected SELECT statement to query if there is a join table record between the school and term with code "FALL06": SELECT * FROM term INNER JOIN school_term ON term.id = school_term.term_id WHERE (school_term.school_id = 1 ) AND (term.`code` = ''FALL06'' ) LIMIT 1 but the INSERT behavior does not include a join table insert if the SELECT does not find an appropriate record: INSERT INTO term (`code`, `name_full`, `name_common`, `date_end`, `date_start`) VALUES(''FALL06'', NULL,...
2005 Dec 16
3
Using :include "recursively" (including the children of the child)?
Hi, Let''s say I have the following hierarchy of tables: Group <- parent Location <- child of Group School <- child of Location Phone <- child of School Then, if I want to do this: Location.find(...someparms..., :include => [:schools, :group, :phones]) I get an association error (Association was not found). I guess it happens because AR is looking in the Location model
2006 Apr 20
4
Question about Associations
Hi all. Got a stupid-simple question about associations. I have two models - school and course. There are a fixed number of schools (set up in the migration). Each course is assigned a school and a school will be associated with multiple courses... How do I set up the associations? Do (can) I have School :has_one :course and Course :has_many :schools? Does the schools table then get a course_id
2007 Oct 15
5
Very simple code throwing "uninitialized constant" error
This code works on an older version of Ruby and Rails but not with Ruby 1.8.6 and Rails 1.2.5. The code is so simple that I can''t figure out where the problem is. profile_controller.rb class ProfileController < ApplicationController def show @profile = Profile.find_by_school_id(params[:id]) end end ----------------------------------------------------------- profile.rb class Profile < ActiveRecord::Base belongs_to :school belongs_to :profile_type translates :text #<--- I''m using the Globalize plugin end ---------------------------------------------...