similar to: setting up has_many

Displaying 20 results from an estimated 10000 matches similar to: "setting up has_many"

2006 Mar 20
11
has_many brings back ''uninitialized constant''
hello. first things first - I am new to ruby on rails (ruby, too), so I''m figuring this is just a basic newbie error. I''m creating a basic photography website. And I have two tables with a relationship: photos: - id (set up as PK) - title - shutter - aperture - date - the_order ...etc photo_comments: - id (set up as a PK) - photos_id (set up as a FK) - author - date -
2010 Mar 31
5
undefined method `each' for "":String
I implemented creating an object within another object according to this Railscast: http://railscasts.com/episodes/74-complex-forms-part-2 but I''m getting this error after I submit. Any ideas? undefined method `each'' for "":String -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this
2010 Jul 15
3
aasm manage states
Is there a way to manage the states in AASM by keeping them in a table to normalize the data? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to
2006 Aug 12
7
Collection assignment to a has_many :through
I''m working on a simple photo gallery in rails, it seems to be a good project for a newbie. I have photos and categories, many-to-many association. It worked well with HABTM. Then I decided that it would be good to be able to change order of the photos so that thumbnail pages would look less chaotic. So I created a Layout model which is a join model (or whatever it is called) that
2011 May 03
2
Database performance for polymorphic associations under high load
Hey guys, I''ve been thinking lately about polymorphic associations, and I wonder: is there a noticeable or tangible performance "hit" from doing polymorphic associations when you''ve got your database under really high query load? So for example, maybe I have a "message" model, a "user" model and an "administrator" model, without any
2010 Mar 18
8
hash in controller is nil after submitting form
I''m trying to create a data entry form but getting an error when it sumbmits. I am using an hash to get the names of the fields definied in the controller''s "new" function: def new @thing = thing.new @columns = Hash.new @columns[''thing_general''] = [ ["title","name"],
2006 Mar 13
1
has_many.collection<<obj doesn''t set attributes?
I tried: @item.stuff<<thing and in thing I have: def stuff_id=(value) # remember old stuff_id cuz Rails has lousy trigger equivalent logger.debug ''set stuff_id called'' end And apparently stuff_id doesn''t get called, but the fk is changed directly in the database? I''m about to abandon trying to do trigger related stuff in Rails and go back to
2010 May 02
8
dev tool
Can anyone suggest a development tool for RoR? How is the plugin for Eclipse? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to
2010 Aug 18
6
Once I added this HABTM, one of my 'through' relationships, on a non-habtm model, seems to have broke?
I''m a rails newb and have been Googling about this, but I''m still stumped. Not showing everything here, but basically it should be a pretty common setup so I''m sure others know what I''m doing wrong. - A meter can belong to many meter_groups - A meter_group can have many meters. - A user can ''subscribe'' to viewing a meter_group (Subscription)
2006 Jul 10
18
Deleting join association of has_many :through
I''m trying to use has_many :through, since my join model deserves being more than just an intersection table. But when I try to break the association, the break only seems "temporary": Let''s say my two tables are Users and Colors, and the join model is Favorites. user = Users.find(1) user.colors.length >> 2 c = user.colors.first >> #<Color:....>
2006 Mar 31
2
"Owning" a polymorphic
I''m playing around with RoR and I''m having trouble figuring out how to describe a certain relationship. I''m building a social networking site where you have users who can comment on other users, photos, videos, and blogs. I''ve figured out how to have a comment belong to a user or media item through a polymorphic relationships but I dont'' know how to
2011 Feb 22
2
tag helper
How can I add specific content inside a tag when I create it using the tag helper? Is there an "inner_html" option? This doesn''t seem to be working. <%= tag(:map, :id => (@module.css_id), :inner_html =>''innerhtml'' ) %> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to
2006 Feb 19
2
Sortable list (scriptalicious) and updating database
I have made a sortable list which is sortable by dragging & dropping the list elements. It works, but the order of the elements will not be updated in the database. Hopefully someone could help me, or tell me what I''m doing wrong. Thnx! Rgds, Eric Controller: album_controller.rb class AlbumController < ApplicationController def show_sort_album @photos =
2005 Jul 22
2
Unpredictable behavoir using Sortable javascript
Hey all, I''m attempting create a photo album that can be re-ordered using the great scipts from script.aculo.us <http://script.aculo.us>. It seems to work as expected when I pretty much copy and paste the puzzle example but when I try and be a bit trickier (changing the movable elements to be divs containing images) things get wierd. I''m able to "pick" the
2006 Jun 24
2
using flickr.rb
Does anyone have any experience with using flickr.rb? Seems the only thing which is documented for it is searching through your photos. Anyway, all I''m trying to do is return a list of my 20 most recent photos, but nothing seems to work. doing this returns 100 photos for a given user (which takes all day to load) @flickr = Flickr.new ''API KEY'' @user =
2007 Jun 09
7
create 2 fk referencing the same table
Hi everyone! I have a problem with defining 2 fk referencing the same table. I have a Program table and a Team table. The Program should have an away team and a home team fk. From my understanding, "the fk column should be named after the class of the target table, converted to lowercase, with _id appended". But, in my case, I have 2 fk referencing the same table. How can I do this?
2006 Apr 11
2
Getting distinct years from a date column the Rails way
I have an original_at column in my photos table. I''d like to get a list of distinct years that occur in this column, and some of the values are NULL. I see two ways of doing this. The SQLish way: photos = Photo.find :all, :select => ''distinct year(original_at)'' This is efficient in that it utilizes the database to do the filtering, and the code is not too ugly.
2006 Aug 14
2
after_create is not being called
Hi all I have the following model: class PhotoGallery < ActiveRecord::Base attr_accessible :title, :description, :file_path, :title_photo_id has_many :photos, :dependent => :destroy belongs_to :title_photo, :class_name => ''Photo'', :foreign_key => ''title_photo_id'' validates_presence_of :title, :description, :file_path
2006 Jun 06
8
How do I wrap a <%= link to %> around an image?
I''ve got a bunch of dynamically generated link paths that I want to use to link some dynamically-generated image paths. Specifically, I want to link thumbnails in a gallery to the larger images. But I''m stymied by Rails'' syntax. I can''t figure out how to do this. I tried this: <%= link_to(image_tag("../../images/photos/photo.photogroup/TN_
2011 Oct 05
3
Rails 3 routes with same name, different param name based on constraint
Hello there fellow RoR enthusiasts, I have been wrestling with rails 3 routes for hours trying to accomplish the following: I want to use the *same url helper* (photo_url) in my views but have a different route match made depending on the format of the parameter I pass. Seems simple enough, right?? If the parameter looks like nn.nn.nnnnnn.whatever, I want the param passed to