Displaying 20 results from an estimated 100000 matches similar to: "create association in rhohub??"
2012 Nov 18
3
remarkable activerecord association RSpec
i''m using gem Remarkable activerecord for association. i''ve installed
remarkable and remarkable activerecrod both gem. i''ve added both gem in
my Gemfile. i''ve added "remarkable_activerecord" as required in
spec_helper.rb.
describe Authentication do
FactoryGirl.build(:authentication).should
belong_to(:user)
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
2011 Oct 11
5
Polymorphic association with Active Admin
I have a belongs_to polymorphic association and I don''t know how to
create and edit my models of that relationship with active admin.
If anyone can help me, please do.
Thank you,
Rodrigo
--
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 Apr 10
6
User Association
Please Im trying to create an application where i can post like twitter,
but i was the users name to be posted under their respective posts
My Post_controller looks like this
def index
@posts = Post.all(:order => "created_at DESC")
@users = User.find(:all)
#@user_id = current_user.find(params[:id])
respond_to do |format|
format.html
end
end
def create
2011 Dec 01
2
Association problem
Hi all
I am using four models user, member, unit, society
I have linked member, unit and society through member_property table
user has one to one association with member while all other models
have many to many association.
How do I link user to member, and user to unit through member
i wanted something like
<%= @user.member.unit.unit_number %></p>
Can someone guide how to
2011 Apr 16
0
adding HABTM association while creating a record
Hello Experts,
I have a HABTM association as followed:
class Account < ActiveRecord::Base
has_and_belongs_to_many :user
end
class User < ActiveRecord::Base
has_and_belongs_to_many :type
has_and_belongs_to_many :account
end
class Type < ActiveRecord::Base
has_and_belongs_to_many :user
end
I have the following query;
I Have a parent user who is creating another user under its
2010 May 07
1
Can't eagerly load a polymorphic association defined in an STI parent class?
If I define an association (in my case a polymorphic one) in an STI
parent class, and try to eagerly load it in a subclass, I get the
following error:
ActiveRecord::ConfigurationError: Association name ''myassoc'' was not
found; perhaps you misspelled it?
If I redefine the same association again in the STI subclass, it
works.
Is this a bug or what?
--
You received this message
2011 Sep 23
1
Simple Association
Hello, I am new to rails and I need a little help getting started with
a simple association. Here is what I am trying to do.
I have a model, message, which has text and a user (do not need to
worry about associating users to messages right now). These messages
come in and I would like to create a response for each, which itself
is a message. Then I would like to create a transaction paring these
2012 Jan 05
3
composite keys and association
i have two table, comment and post, both have composite keys, and no id
column, comment belongs to post, i follow the instruction of
http://compositekeys.rubyforge.org/, and it seems successfully,
(But i still cant confirm to put require ''rubygems'' and
require ''composite_primary_keys'' on which file ).
I can do the CRUD operation for post,then i want to create
2014 Apr 19
0
How to has_one/belongs_to association only return the objects unassociated in combobox?
I have two models (Car and Driver) and a combobox to select which driver
belongs to which car. I want the combobox just show the objects that have
not yet been associated.
# vehicle belongs_to: driver
# driver has_one: vehicle
# simple_form # vehicle/_form.html.haml
= f.association: driver, label_method: :name, value_method: :id
How to ensure validation before saving, to avoid problems of
2012 Jul 14
0
Adding to an association from a long list of items
This is a beginning Rails question. I have two models, Member and
Organization, in a one-to-many association. (An Organization can have many
Members.) The problem is I''m not sure how to design a view/controller that
allows the user to associate an existing Member to an Organization. One way
is to create a big HTML Select tag containing Member.all, and allow the
user to pick the
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 Apr 10
1
accepts_nested_attributes + polymorphic association
im having an issue where my my polymorphic associations arent being
deleted when using accepts nested attributes
there are other accepts_nested_attributes being used and they are
deleting fine, just the polymorphic association
before i go down the path of intense thrashing at this...is this a known
issue or problem?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because
2010 Mar 13
6
Find first or create
Is there any ActiveRecord''s dynamic finder that can allow me to find
first association or create it if it doesn''t exist. Something like this
(not this code is conceptual - it does not work!):
Comment.posts.find_or_create(:first)
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2010 Nov 30
3
how to 'delete' an object from an association collection in-memory only
Hi,
My Rails app offers opportunities to try out models on a ''what-if''
basis, where dependent associations can be modified to obtain
alternative results for the parent. Is there a way to delete/destroy
the member of a collection so that I can play around with the
accordingly modified parent in memory, without actually committing the
destruction of the collection member to the
2013 Jan 04
0
Add data in between Simple Form association members
Hey there,
I am trying to use Simple Form''s association to list a bunch of radio
buttons like so:
<%= simple_form_for(@applicant) do |f| %>
<%= f.association :track, :as => :radio_buttons %>
<% end %>
Assuming each track has many courses, how can I take every track from that
association and loop over its courses to display them below the radio
2012 Jul 10
1
has_many association with autosave issues
I''d like to use autosave => true for an association for its added benefits:
the parent doesn''t save unless the children saves. However, it seems to
skip validations when saving the children. And this seems to be the case
since the beginning of time...
Anyone know why?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2011 Sep 04
1
polymorphic association
Hello,
I have a scenario where I want to save a author image and book image to
assets table...
I am using a polymorphic association.
And author_name is inside the books table.
now when I save the image the imageable_type says "Book" for both. And
off-course it''s a correct behavior, but I am just trying to figure out is
there any way where I can save author image and
2010 Dec 07
1
fields_for and one out of many from association
class Person < ActiveRecord::Base
has_many :addresses
has_one :primary_address, :class_name => ''Address'', :order =>
''preferred desc, id''
accepts_nested_attributes_for :addresses, :allow_destroy => true
accepts_nested_attributes_for :primary_address, :allow_destroy =>
true
end
class Address < ActiveRecord::Base
belongs_to :person
end
2012 Dec 24
4
Bad idea to add/remove associations in after_find
I have 2 distinct types of users (artists and curators) in my system and
they currently share all associations (eg has_one :portfolio).
However, a curator shouldn''t have a portfolio so I would like to only
add that association when required. Obviously I could just return nil
for that method, but it doesn''t feel right having that there in the
first place.
What''s the best