search for: attachable_id

Displaying 9 results from an estimated 9 matches for "attachable_id".

2007 Sep 18
2
Making attachment_fu polymorphic
...p Attachment_kung, ## 1. Create the Attachment_fu model and table (I used Attachment and attachments), ## set them up for polymorphism. Add to the table a column called path_prefix. ## (I used: belongs_to :attachable, :polymorphic => true for the model and attachable_type and ## attachable_id for the table); and configure the Attachment_fu model with ## has_attachment :storage => :file_system ## include Attachment_kung ## Make sure Attachment_kung is *last*, or you will not be able to display your attachments. Also, ## I have not tested Attachment_kung wit...
2008 Sep 29
1
has_one :through with :source. How to alias association?
...er'', :dependent => :destroy, :conditions => [''attachments.content_type = ?'', ''image/jpeg'' ] produces the same results of: has_one :another_logo, :class_name => ''Attachment'', :foreign_key => ''attachable_id'', :conditions => [''attachable_type = ?'', ''Maker'' ] Which one is the best approach to achieve the desired result? Thanks in advance for your help -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You re...
2006 Apr 22
9
one to many question
1. A category has parent categories. 2. A product is in many categories and a category has many products. 3. Products and category both have images in the same image table. ie. a product and / or category could have multiple images.<=== my question is related to this So among other things I presume I have to do the following: class Category < ActiveRecord:Base #...
2006 Sep 22
2
possible to create polymorphic relationship with STI models?
...s for :class_name and :foreign_key are ignored, as the association uses the source reflection." 1. Attachment tables: 2. 3. (polymorphic attempt) 4. create_table "attachments", :force => true do |t| 5. t.column "product_id", :integer 6. t.column "attachable_id", :integer 7. t.column "attachable_type", :string 8. t.column "created_at", :datetime 9. t.column "created_by", :integer 10. end 11. 20. 21. Models: 22. class Product < ActiveRecord::Base 23. has_many :parts, :through => :attachments,...
2007 Oct 09
5
Backticks wrapping SQL values in polymorphic associations...
...nt belongs_to :attachable, :polymorphic => true end Calling Part.find(:first).attachments yields this SQL error: ActiveRecord::StatementInvalid: Mysql::Error: Unknown column ''Part'' in ''where clause'': SELECT * FROM attachments WHERE (attachments.attachable_id = 1375 AND attachments.attachable_type = `Part`) If I change the backticks to single quotes it runs fine in MySQL. But... why are there backticks? Is that per design? Is there something wrong with my MySQL install? (MySQL version 5.0.37, InnoDB format) Any ideas? -- Posted via http://www.r...
2006 Feb 10
3
[Req] polymorphic associations howto
Hi people, I''m looking into polymorphic associations as a way to cleanup some messy parts of my code. I think they will allow me to do exectly what I need, but since there''s little to none written on this subject, I''d be delighted if someone could shed some light on this. Especially what the different options and needed table structures need to be. Thanks, -
2006 Feb 15
2
Polymorphic joins work one way, but not the other
...parse documentation popping up but it seems to cover a somewhat different case. Anyway - I pretty much got it to work - save for one detail. Here''s what I have: class Event < ActiveRecord::Base belongs_to :attachable, :polymorphic => true #events table has attachable_type and attachable_id fields end class Task < ActiveRecord::Base has_many :events, :as => :attachable #tasks tables is nothing special end and now a unit test: #there''s some fixtures above def test_polymorphics assert tasks(:simple_task).events << events(:simple_event_1) assert tasks...
2007 Dec 20
3
ActiveRecords Eager Loading
...l_ranking desc", :limit=>20) --------------------------------------- the above statement resulted in this expensive query. After indexing, it take about 3 seconds to execute. (before indexing it is about 25 seconds) SELECT DISTINCT articles.id FROM articles LEFT OUTER JOIN assets ON assets.attachable_id = articles.id AND assets.attachable_type = ''Article'' LEFT OUTER JOIN votes ON votes.voteable_id = articles.id AND votes.voteable_type = ''Article''AND user_id = 2 WHERE (assets.parent_id is null) ORDER BY stat_final_ranking desc LIMIT 20 ---------------------------...
2011 Oct 26
6
Add an index to a form
Hello, I''m having some trouble with forms, my app allows to enter data by using a multi-step form that has 7 steps. There are 3 steps that may let the user to add 1 form, for example there''s a step called "children" and that children has the following fields: * name * age * gender but one father may have more than 1 child and I''m adding another form with