similar to: Rails 4 "belongs_to: record" association doesn't work

Displaying 20 results from an estimated 20000 matches similar to: "Rails 4 "belongs_to: record" association doesn't work"

2013 Jul 21
4
how to use activemodel collection.build for a has_many :through association
Hi all, In my controller I am doing the following to populate a nested form for a has_many through association: def new @specification = Specification.new Component.find_each.each do |component| @specification.component_specifications.build(:component_id => component.id) end The idea being whenever someone creates or edits a form, it will be populated with all
2013 Nov 10
3
accepts_nested_attributes_for how, example
I have following tables with following models: users(id, role_id) *has_many :entries* categories(id, category_name) *has_many :entries* entries(id, category_id, user_id) *belongs_to :user, belongs_to :category, has_one :storage* storages(id, title, content, entry_id)* belongs_to :entry*, *has_one :vote* votes(id, count, storage_id) *belongs_to :storage* Now,
2006 May 17
2
Association data clobbering (foreign keys too?)
Can someone please confirm or correct the following statements? If I have the following tables create table as (id int, [...], b_id int); create table bs (id int, [...], a_id int); create table as_bs (a_id int, b_id int); and the associations woould be defined like this class A << ... habtm :bs belongs_to :b end so my Model A has a habtm collection of Bs *plus* a direct
2006 Nov 04
2
sql query in active record
hi all, if i want to write a query select * from a,b where a.b_id=b.id in active record using joins,condition how can i write that in docs i found for conditions you do by giving "?" and then the parameter eg. a.b_id=? but it takes b.id as string i.e a.b_id=''b.id'' i dont want that any suggestions thanks in advance regards gaurav -------------- next
2013 Jul 11
1
Do I Edit the Migration Too to Show the Belongs To
Hi Everyone, Do I edit the corresponding migration also to show the belongs_to (and the has_many)? I have a many to many relationship where I am using the "has_many :through" association. When I place in the individual classes the ''has_many :through'' and the ''belongs_to'' associations, do I also edit the corresponding migrations to reflect those
2012 Aug 17
3
Rails doesn't validate create_model or build_model (has_one association)
I''ve got User has_one Shop. Rails is not validating when I tried create_shop or build_shop, neither in the browser nor the rails console. My code: class Shop < ActiveRecord::Base attr_protected :user_id belongs_to :user validates_presence_of :name, :primary_address, :city, :country_code, :currency end class ShopsController < ApplicationController before_filter
2013 May 31
11
A simple javascript alert not working
If I have a file in view /test called index.js.erb and in it a simple alert("hello") shouldn''t that run when I go to /test/index? It doesn''t. -- 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 unsubscribe from this group and stop receiving emails from it,
2013 Aug 30
3
frozen? is defined by ActiveRecord
Hello folks I got that error Pls tell me what''s wrong frozen? is defined by ActiveRecord -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this
2008 Jul 04
2
How to make WHERE foo_id IN () query?
Hi, There are 3 models: A has_many :Cs B has_many :Cs C belongs_to A and B I got a single object of A and an array of B objects. How can I get all Cs that have a_id equal to object A.id *and* b_id that belongs to an object in Bs array? Regards --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2013 Oct 24
6
undefined method `paginate' for #<Class:0x567eb98> in Rails Tutorial
Hi, I''m getting a undefined method `paginate'' for #<Class:0x567eb98> even though I have gem ''will_paginate'' installed. Inside the users_controller I have @users = User.paginate(page: params[:page ]) so I believe I set everything up to be correct. Can you figure out why the method''s undefined, despite installing the gem? -- You received this
2006 Dec 30
2
search on multiple table
Hello, I am trying to make a search, using acts_as_ferret on a has_and_belongs_to_many relation : class a < ActiveRecord::Base belongs_to :b has_and_belongs_to_many :c Joboffer.find_by_contents( query +b_id:1 ) is working fine but Joboffer.find_by_contents( query +c:1 ) is not working Here are the tables descriptions: Table a have field : id, b_id Table b have field : id,
2013 Oct 23
9
rails generate scaffold - ERROR
Hi, I just installed ROR using the rvm using these instructions: http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/ Using Ubuntu 12 on VirtualBox I''m trying to create a demo_app rails generate scaffold User name:string email:string gives me this error: -- /home/natmanu/.rvm/gems/ruby-2.0.0-p247/gems/execjs-2.0.2/lib/execjs/runtimes.rb:51:in `autodetect'': Could not
2013 Jul 25
3
User Role authorisation
Hello, Currently I am working on a app, so far I have User (with devise) which are able to create projects. So, if user1 creates project A and project B I want him, to be able to assign user2 with role admin on project A, and user2 with moderator role on project B. I was thinking in creating a UserRoleProject link table, is it a good idea? Or if not please help me with some pointers. The action
2009 Jun 27
6
User has many topics or subtopics
Hi, So i have users in the system and i have topics. Topics also have_many subtopics. What is the cleanest way to setup the AR relationships if a user can either have_many topics or subtopics ? Its basically a dual select box dropdown, where the second dropdown is optional. Is the best to have user_topics, and user_subtopics tables and manage that way ? or combine into one table with STI
2013 Oct 04
8
is there any way to convert .xlsx to .xls
Hello Guys, does anybody know if there''s anyway to upload a .xlsx file and then convert it to .xls file for later processing? i''d like to use spreadsheet to write a new xls file but it doesn''t support xlsx and the file is only importable with that format sadly. I saw roo but I don''t know if there''s a direct way to do it. -- You received this
2013 Jun 21
7
IRB help
I''m new to Ruby. I installed Rails on Windows 8. When I type mkdir in IRB, I''m getting this. I tried running the IRB as administrator too, and still get the same result irb(main):001:0> mkdir lesson2 NameError: undefined local variable or method `lesson2'' for main:Object from (irb):1 from C:/RailsInstaller/Ruby1.9.3/bin/irb:12:in
2011 Mar 01
11
Did rails or shoulda go insane on the inflection of 'taxes'?
I have a model ''xp_jurisdiction_taxes'' which rails (3) created correctly. Another model ''xp_jurisdiction_states'' has many :xp_jurisdiction_taxes. In my spec I am using a shoulda helper to test the association but get the following error. BTW, greped the whole project just in case and the string ''taxi'' exists nowhere. 1)
2011 Jul 11
36
has_many and belongs_to association
Hi , I want to test the one below but I got the problem belongs_to :name, :class_name => "Phrase", :foreign_key => "name" in my test context "test"do should have_many :phrases end in language.rb belongs_to :name, :class_name => "Phrase", :foreign_key => "name" error is 1) Failure: test: check has_many and belongs_to
2013 Feb 25
3
ActiveRecord associations: design question
Hi guys, In my Rails app, I have three models: A, B and C, with the following relationships: - B hasMany C - C belongsTo B I would like A to "has_one" instance of B+C. By that I mean A needs to be linked to a specific instance of B AND a specific instance of C. My first guess would be to create a fourth object, say B_plus_C that would: - belongs to B - belongs to C - belongs to A Is
2010 Jun 24
11
Error: Trying to install passenger-install-apache2-module
i am trying to install passenger-install-apache2-module but it is giving me the error. E: could''nt find the package passenger-install-apache2-module Please help me over this. -- 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