Displaying 20 results from an estimated 30000 matches similar to: "there is no documentation about before_add_for methods?"
2011 Jul 25
1
3 models in a form.
Hello,
class Customer < ActiveRecord::Base
has_many :deliveries
class Delivery < ActiveRecord::Base
has_many :delivery_items
has_many :products, :through => :delivery_items
belongs_to :customer
class DeliveryItem < ActiveRecord::Base
belongs_to :delivery
belongs_to :product
I create a new delivery for customer x:
= simple_form_for @customer do |f|
= f.simple_fields_for
2011 Nov 12
3
complex form with dynamic fields.
I''ve seen http://railscasts.com/episodes/73-complex-forms-part-1,
part2 and part3.
It seems to be my case.
I have:
Company
has_many :documents
has_many :tenders, :through..........
and
Document
belongs_to :company
Tender
has_many :companies, :through..........
I want to insert documents and tenerds on company creation.
If documents are more than one the user can click "add
2012 May 10
6
Is it suitable using STI?
I have problems on a simple design problem.
I have many companies. Each company have one or more commercial activity.
Activities types are: ecommerce, local unit, television, automatic
vending machines, and so on.
Company may have one or more ecommerce activity or one or more local
unit activity, one ormore vending machines, etc.
How can I model this scenario?
Company has_many ecommerce has_many
2011 Feb 11
1
accept_nested_attributes, reject_if doesn't work.
class Post < ActiveRecord::Base
validates :name, :presence => true
validates :title, :presence => true,
:length => { :minimum => 5 }
has_many :comments, :dependent => :destroy
has_many :tags
accepts_nested_attributes_for :tags, :allow_destroy => :true,
:reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? or v.nil? } }
end
rails c
2011 Sep 15
1
bypass defualt scope.
class Shop < ActiveRecord::Base
has_many :documents, :dependent => :restrict
end
class Document < ActiveRecord::Base
belongs_to :shop
default_scope :order => ''updated_at DESC''
end
in the Shop show view I have:
- for document in @shop.documents
%li(id="shop_documents")= link_to document.subject,
shop_document_url(@shop, document)
I want list
2010 Dec 25
6
undefined local variable or method?
I have:
<%= form_for(@supplier) do |f| %>
.......
......
<%= render ''sector_categories'', :locals => {:f => f} %>
in _sector_categories partial I have:
<div class="field">
<div id="category_update">
<% for category in @categories %>
<%= f.check_box :category_ids[], category.id,
2013 Feb 23
0
where condition having no association
Rails 3.2.11
My app has a model called Plan, which has has_many self-referential
association just like
http://railscasts.com/episodes/163-self-referential-association
has_many :matches
has_many :counterparts, :through => :matches
has_many :inverse_matches, :class_name => "Match", :foreign_key =>
:counterpart_id
has_many :inverse_counterparts, :through =>
2013 Sep 17
4
Rails 4 deprecation of in-place edit methods for collection associations
Hi everyone!
For those of you who are not noticed the in-place edit method for
collection associations are broken in the current rails release - 4.0.0,
and here''s what is cooking in the rails master
https://github.com/rails/rails/commit/1a40be02113287d9a003f8224e91b9f623857f4b
and this https://github.com/rails/rails/pull/12227
In short: it looks like things like has_many.reject!{},
2010 Aug 19
1
has_many :through question
I am trying to create an association table using the ":through" option
in "has_many" but not having success. I have created the necessary
migrations of the association tables and run rake db:migrate
I have the following model:
class Group < ActiveRecord::Base
has_many :users, :through => :group_user
has_many :invites, :through => :group_invite, :class_name =>
2013 Jul 16
0
Which object have my association extension method?
My Stackoverflow question:
http://stackoverflow.com/questions/17461273/where-does-association-extension-sit-in/17664817?noredirect=1#17664817
I have an association extension method like the following:
class Bundle < ActiveRecord::Base
has_many :items do
def foo
end
end
I was trying to use delayed job/sidekiq delay() method like the following:
b.items.delay.foo
But I
2010 Jan 08
1
problem using build with has_many :through relationship
Hello all,
I''m having problems creating a new record with has_many :through
My application is quite complicated so I''ll try to explain it as easy as
I can.
I have a many to many relationship with Projects, IRBs and Reviews.
Where reviews is the joined model.
In the new project view, I have a link (add IRB). This will add an a
list of IRBs to the new project form.
I have visited
2010 Apr 09
2
Vestal Versions Related Records
I need to keep version of a model Client:
has_many :product_clients
has_many :products, :through => :product_clients
The question is what is the best way of saving versions of the
association. Can I make the association using the client.version.id
rather than the client.id? Or should I use a bit mask?
Any thoughts much appreciated,
Mike
--
You received this message because you are
2010 Jun 29
3
belongs_to. Association methods don't pass data to DB
Hi.
I have a problem with the association methods which passed to a model
through a belongs_to declaration. Here''s an illustration of the issue:
GIVEN:
# migration
class CreateArticlesAndAuthorsTables < ActiveRecord::Migration
def self.up
create_table :articles do |t|
t.text :title
t.integer :author_id
end
create_table :authors do |t|
t.text
2013 Feb 08
1
Problem with many to many relationship
Hi
I''m trying to create a many to many relationship between two models.
A User can be associated with many Incidents and vice versa.
class User < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
has_many :incident_participants, foreign_key: "participant_id"
has_many :participated_incidents, through: :incident_participants
end
class Incident
2011 Jun 15
5
rails 3.0.9
Today was expected the new stable rails release 3.0.9 with some fixed,
among all the problem with escape_javascript.
It seems that it see that has not been released, unfortunately.
--
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
2012 Jan 18
2
Polymorphic and standard association issue
Hello all,
I''m having a strange issue with a model that belongs_to two other
models. The one association is polymorphic and the other is normal.
================================
class Role < ActiveRecord::Base
belongs_to :user
belongs_to :permission, :polymorphic => true
end
class User < ActiveRecord::Base
has_many :roles
has_many :programs, :through => :roles
end
2013 Dec 17
1
Tire: Problem with including associations while doing a multi-model search
I am using elasticsearch for querying in my application. Lets say there
are 2 models
Class Topic
has_many :posts
and
Class Article
has_many :comments
I want to do a combined search on both these models and my query looks
like:
Tire.search [Article, Topic], {:load => {:include => [:posts,
:comments]}} do |search|
...
end
This is where I encounter a problem. I get the
Association
2011 Aug 17
1
has_many :through, collection<<(object) and duplicates.
Hi,
I''m facing a strange behavior in Rails with the has_many association and
the generated collection<<(object, ...) method that comes along.
I''ve got an Object model and a Tag model, plus a taggings table to join
the two together.
On Object, I set these associations:
has_many :taggings, :as => :taggable, :dependent => :destroy
has_many :tags,
2011 Sep 04
2
has_many :through basic fubar
I''m trying to do, what seems like, a very basic join. However, the
association just doesn''t seem to work. I''m sure it''s something very
simple but I don''t know what.
class Role < ActiveRecord::Base
belongs_to :packages
belongs_to :users
end
class Package < ActiveRecord::Base
has_many :roles
has_many :users, :through => :roles
end
2010 Mar 01
0
undefined method for Polymorphic association using Searchlogic
I am unable to call a polymorphic scope using the searchlogic plugin
as it keeps on returning ''undefined method''. I am certain it is only a
problem within my project as I created a test project and I was able
to call a polymorphic scope using the searchlogic plugin.
I am hoping someone can provide a suggestion on how to debug this
issue.
My project consists of several gems, and