similar to: record will absolutely not save! so weird, please help.

Displaying 20 results from an estimated 100 matches similar to: "record will absolutely not save! so weird, please help."

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
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
2006 Feb 11
2
Migrations and Unintialized Constants Error
I am running into a problem with two of my tables and the "uninitialized constant" error when using migration. I get the "uninitialized constant Note" when running the following code in my migration file: create_table :notes do |t| t.column :id, :integer t.column :noteshare_id, :integer t.column :title, :string t.column :covered, :string
2009 Aug 28
2
Association extension method
In my application a user working at a dropzone can manipulate transactions against customer accounts. Here''s my models: class Transaction < ActiveRecord::Base belongs_to :account end class Account < ActiveRecord::Base belongs_to :dropzone has_many :transactions end class Dropzone < ActiveRecord::Base has_many :transactions, :through => :accounts do def
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
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 Jun 13
7
model validation across multiple views
I have a rather complex object with a number of attributes. For a variety of reasons, I would like one view to create the object with only a couple of fields completed, then a second and third view to finish all the fields. I would like the model to validate_presence_of all these fields, since eventually I need them all there, and I would like each page to validate its portion of the fields that
2006 Jul 25
1
save trouble with has_many belongs_to relationship
I have a bit of code in a controller that looks like this: @current_festival.monitor_preferences.each do |pref| if pref.user_id == @me.id pref.preference = params[:monitor_pref] #pref.save end end @current_festival.save_with_validation(false) the Festival class has_many :monitor_preferences the MonitorPreference class belongs_to :festival In the configuration above, the
2006 Mar 27
1
Best way about doing this?
Hi All, I''m super a super ruby nuby, so bare with me. I am working on a small app that has a particular form that I am having a rough time figuring out the best to way to handle. Basically here it is, each school has one or more classrooms, and each classroom can have one or more teachers. Here''s what I am trying to do (edit a school): - click on a link to edit a School -
2006 May 11
2
Login Generator and Salter
okay, I''m using login generator. And when I log in alwase get failed. So I looked at my log, I gatherd infomation that says on creation the salted pass was: 2b8b06e5a650a4b97f146e6b5ae7ab82c43707e on login the salted pass is: 2b8b06e5a650a4b97f146e6b5ae7ab82c43707e and in my DB it is: 2054d52ca901ff70b5a334cb3e13d8c67940c3f3 So in my DB it change why? -- Posted via
2008 Apr 11
2
Validating an ActiveRecord object and its has_many :through associations
Considering an object with several has_many :through => associations, what is the ''best'' way to handle validations? As an example: class Student < ActiveRecord::Base # some attrbutes like # :name # :grade # relationships has_many :students_assignment, :dependent => :destroy has_many :assignments, :through => :students_assignment has_many
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] =
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
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.'' #
2006 May 12
1
Some error about adding.
Ok so I''m trying to make a little exchange 3 for 1 of 1 higher rank here is the code in the controller: def exch_link @id = @session[:user].id @type = @params[:type] exch(@id,@type) end def exch(user_id,this_type) @user = User.find(:condtions => "id = " + user_id) @ranks =
2006 Jul 27
0
Controllers, Models, and Validations...
Hello, After listening to DHH''s 2006 RailsConf keynote, I decided to take a leap on my current application and do a little more re-organizing to make it more CRUD-based. As such, I ended up changing some things around to get this (simplified): User has_many :enrollments, :conditions => ''status > 0'' User has_many :schools, :through => :enrollments User has_many
2006 Jan 19
2
Easy way to handle form input without a model class?
I have a couple forms that I''d like to be able to validate and automatically populate, but it shouldn''t be based on AR. In fact I often have a bunch of small forms that I can''t really justify writing a whole new model class for anyway. I''d like to validate the form input, and then use rails helpers to automatically populate the form if validations fail.
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...
2005 Dec 26
3
Override Validation?
Hi all, is there a way to override the validation methods so as to avoid the div.fieldWithErrors divs from being created on the redisplayed form? Many thanks in advance, Nicky
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