similar to: Help needed for error in foreign key validation

Displaying 20 results from an estimated 1000 matches similar to: "Help needed for error in foreign key validation"

2012 Dec 16
3
Running code in another controller action
I am doing a partial render in the view from one controller. Here is the code -> <%= render :template => ''restaurants/new'' %>. I want the other controller new action code to do it. Is there a way to call an action in another controller ? I don''t want to duplicate the same code in two controllers. -- You received this message because you are
2006 Jul 28
3
Forms: handle foreign keys (AssociationTypeMismatch)
Hi all I tried and tried and tried, but I still fail in creating a form with proper validation and stuff for foreign keys... So I''d really like to get some help here. I''m creating a booking site for DJ''s, and for every booking one can choose one of different countries: class Booking < ActiveRecord::Base validates_presence_of :country_id
2013 Mar 25
1
validates presence of foreign key fails in nested form
I''m using accepts_nested_attributes as follows: class Timesheet < ActiveRecord::Base attr_accessible :status, :user_id, :start_date, :end_date, :activities_attributes has_many :activities, dependent: :destroy has_many :time_entries, through: :activities accepts_nested_attributes_for :activities, allow_destroy: true end class Activity < ActiveRecord::Base attr_accessible
2007 Oct 16
12
Example for attr_accessible?
Is anyone out there writing specs to check attr_accessible fields? I had originally written my spec to check for allowing the desired fields, and then none of the other regular db fields. Unfortunately this isn''t satisfactory, because attr_protected could have been used instead, which of course wouldn''t prevent mass assignment to any whatever=(val) method. I''m thinking
2010 Mar 26
7
seed data
Hi I am using seed_fu to seed initial data to tables (http://github.com/mbleigh/seed-fu) . And in db/fixtures/state.rb I have values like (I am filling only two data for simplicity) State.seed_many(:name, :abbr,:fips,:country_id, [ { :name => "Alberta", :abbr => ''AB'',:fips => ''01'', :country_id => 2 }, { :name =>
2009 Jan 28
3
Apply style in collection_select ?????
Hi to all, i have this snip i want to apply style to this combo but there is no effect help....... <%= collection_select(:customer,:country_id, @countries,:id, :country, html_options={ "style" => "width:110px" },:onchange => ''updateState('''');'',:id =>''country_id'' )%> Thanks, -- Posted via
2012 May 28
4
How to load a selection list into the method new of a controller?
Hi friends! I''m relatively new with Rails and I''m struggling for a long time with this problem (it should have a pattern solution but until now I didn''t find it): I have the following models: Institution, City, State and Country. class Country < ActiveRecord::Base has_many :states has_many :cities, :through => :states end # == Schema Information # Table
2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come in. Console just gives me back :account_id => nil. Obviously I''m trying to set it though. Silly console... But, I can set the account_id column in my controller like so: @user = User.new(params[:user]) @user.account_id = account.id @user.save Here''s what I give to the controller: User.create :name
2006 May 16
1
ActionMailer w/o database link (e.g., feedback form)
Hey, A total noobieQ. Apologies, still learning. Could anyone point me to examples of a non-database-driven feedback form, for instance, a simple e-mail feedback form that takes advantage of ActionMailer? (How do I carry a POST through to a ''def'' w/o a database connection?) Thanks! -- Posted via http://www.ruby-forum.com/.
2007 Nov 07
5
Unexplainable failure...at least for me
I have an address model with country_id and province_id fields There is also a full_address method that returns an address that is in a format that the google maps api will be able to return a long-lat coords. Within the full_address method there is a call to obtain the province/state and country name. --------- def full_address ... full_address = [city, self.province.name,
2006 Jul 27
2
Creating multiple objects from form data
I''m in the process of creating a sign up form for an online application. The form collects account info, company info, and then info for an administrative user. The method looks like this: def create @account = Account.create!(params[:account]) @company = @account.companies.create!(params[:company]) @user = @company.users.create!(params[:user]) end However, this inevitably fails
2010 Nov 09
2
Undefined method
I am very new to ROR. (Ruby 1.8.7, rails 2.1.1, rack 0.8.7, mysql 5.1.41) I has my_app/lib/migration_helpers.rb file: module MigrationHelpers def self.foreign_key(from_table, from_column, to_table) constraint_name = "fk_#{from_table}_#{to_table}" execute %{alter table #{from_table} add constraint #{constraint_name} foreign key (#{from_column})
2012 Jul 09
10
attr_accessible on some properties + attr_protected on others makes class 'open-by-default'
(I posted this as a bug in GitHub (https://github.com/rails/rails/issues/7018), but then someone there told me I should post it here, so here it is.) If you set attr_accessible on some properties in an ActiveRecord-descended class, and then attr_protected on others - the class becomes ''default-open'' - if any properties are missed or added later, they will be accessible by
2006 Feb 15
8
Agile book - getting confusing error
Working through the beginning phase from the Agile book on ''Administration'' undefined method `hashed_password='' for #<User:0xb7911324> ... /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1498:in `method_missing'' #{RAILS_ROOT}/app/models/user.rb:12:in `before_create''
2012 Dec 29
2
I need intercept in plm model
Hi,R 2.15.2 plm() function on Windows 7 when i perform a plm regression, i can't manage to obtain the intercept, but I need it.it gives me just the beta coefficient. my formula: fixed <- plm(deltaS ~ L1.deltaS + L2.deltaS, data=Mody_R, index=c("country_id", "date"), model="within") my output: Coefficients : Estimate Std. Error t-value Pr(>|t|)
2007 Jan 24
2
attr_accessor vs attr_accessible
Please guide me how to use those two methods. I can''t differentiate them. I was doing something on my model and I have put one field in the attr_accessible method. After that when I try to run the app the app always says my other fields are blank, but they''re all filled up. What''s wrong with it? Thanks --~--~---------~--~----~------------~-------~--~----~ You received
2006 Jan 12
9
Scaffold shows all attributes altough I use attr_accessible!
Hi all I have a Model like this: class Member < ActiveRecord::Base attr_accessible :username, :email, :first_name, :last_name end I have created a scaffold using script/generate scaffold member members Using the URL localhost:3000/members/edit/1 I can edit all attributes, including created_at, lock_version etc.! But it should only show the attributes I listed in attr_accessible! What
2011 Jun 11
1
Having a problem adding a foreign key
I keep getting this exception "SQLite3::SQLException: no such column: books.user_id: SELECT "books".* FROM "books" WHERE ("books".user_id = 4)" ,which sounds like there is no user_id in books table.So i just installed foreigner plugin and added " t.integer :user_id, :null => false" and "add_foreign_key(:books, :users)" in book
2010 Nov 02
7
Testing attr_accessible (and/or attr_protected)
I''ve been puzzling over how to test that attr_accessible has been set for the correct columns; but the tests I''ve come up with so far seem to fail to fail when I expect. I came across this old message from this list: http://www.mail-archive.com/rspec-users at rubyforge.org/msg01570.html Which seemed like a plausible example, but my attempt (modeled on the example)
2006 Jul 02
1
multitable form
Hi all, Although I''m experienced with programming I''m a beginner with ruby, RoR and MVC So I follow examples from books and so on and all is ok. I can make a model who is a class and who match to a table in my database and then I generate pretty forms on a webpage. I would like to know how I can do to make forms who interact with more than one table. For an example lets