similar to: Updating a form containing array of text fields with has_many/belongs_to relation?

Displaying 20 results from an estimated 5000 matches similar to: "Updating a form containing array of text fields with has_many/belongs_to relation?"

2010 Apr 06
1
captcha in a belongs_to
Hi I am using simple_captcha. I have two models User and Staff. Relation ship are User has_one staff staff belongs_to user Now in the staff edit I have to include a captcha. I did like <% form_for @user, :url => staff_url(@staff), :html => {:method => :put } do |f|%> <p> <%= f.text_field :first_name,:maxlength => 50 %> </p>
2010 Dec 23
0
has_many :through full stack help
I am trying to implement HMT for the first time and having a ton of trouble. I would like to be able to have the user check a checkbox and fill some extra fields for data input. I have tried so many iterations borrowed from different places I found on the web, none seem to work quite right. Essentially I have two models: ''practice'' and ''system'' where a
2007 Nov 22
1
has_many :through questions
I''ve created the following associations using :through: class Person < ActiveRecord::Base has_many :attendees, :dependent => :destroy has_many :events, :through => :attendees, :uniq => true end class Event < ActiveRecord::Base has_many :attendees, :dependent => :destroy has_many :people, :through => :attendees, :uniq => true
2006 May 29
9
design recommendations for authenticating users with lots of different attributes..?
I''ve been struggling a bit trying to figure out the best way to design/implement a system with authentication/authorization, and was hoping some of you may be able to offer some advice.. At the moment, I have a system with 4 different types of users - clients, administrators, sales_reps, and public_users. I''m using "Authorizing Users with Roles" from the Rails Recipes
2012 Nov 03
0
ids writer fields for HABTM relationship.
Hello forum readers, Let''s say i have two models: Person and Role (i replicated the problem with Post & Tag as well, as i thought the problem was linked to some application-specific rights problem, but it wasn''t). In Person, attr_accessible role_ids is declared, so it accepts an array of Role ids as an argument when creating / updating. If i fire up the rails console and
2006 Jul 22
3
refactoring commonly used aggregations
I have a number of models that use an aggregation to combine First Name, Middle Initial and Last Name and they have been working fine. I am looking to clean this up, DRY it if possible. I have things like this in application.rb class Clwholename attr_reader :first_name, :middle_initial, :last_name def initialize(first_name, middle_initial, last_name) @first_name = first_name
2006 Jul 11
1
counter_cache, has_many and belongs_to
I am a bit confused about counter_cache here. The API docs http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html say that only the belongs_to association can take the :counter_cache option. When I try to use it on a has_many I get an "unknown key(s): counter_cache" error. Why would this be the case? belongs_to means that this model has a field with an id
2006 Jul 25
1
save trouble with has_many belongs_to relationship
I have a bit of code in a controller that looks like this: @current_festival.monitor_preferences.each do |pref| if pref.user_id == @me.id pref.preference = params[:monitor_pref] #pref.save end end @current_festival.save_with_validation(false) the Festival class has_many :monitor_preferences the MonitorPreference class belongs_to :festival In the configuration above, the
2006 Jul 31
0
Issues with has_many, belongs_to and dependency settings
I have 2 models SmsAddress & OutboundSmsAtom SmsAddress { has_many :other_objects, :dependency => :nullify } OutboundSmsAtom { #note this object also "belongs_to" other objects if that matters belongs_to :this_object } Whenever I try to destroy an object of type ThisObject, which at the time has 0 "children" OtherObjects I get the following type of
2006 Jul 31
0
Polymorphic has_many association through a belongs_to
Hi, Let''s say I''ve the following Models and their relative associations: Seat ---- belongs_to :booking Booking ------- has_many :seats has_many :debits, :as => :chargeable Debits ------ belongs_to :chargeable, :polymorphic => true Why >> seat.booking.debits nil while >> Booking.find(seat.booking_id).debits [] ? Thanks. Cheers, Marco
2006 Apr 07
0
Updating a relationship in a has_many and belongs_to
As the subjects suggests I''m trying to reiterate through certain pages, assigning them to certain menus. My code is as follows When I run the Below the position updates fine, but the menu_id in Page doesn''t seem to change it all. params["group_#{params[:id]}"].each_with_index do |id, position| Page.update(id, :position => position + 1, :menu => menu) end
2006 Apr 16
1
has_many :through and belongs_to
I have a relationship where a Show has_many Techs through People. From what I understand that requires me to put belongs_to Show in the People model. My problem is that a Tech can belong to many Shows. Is there any way of solving this besides putting a has_many Shows relationship in People -- Posted via http://www.ruby-forum.com/.
2007 Oct 07
1
activerecord problem with contrains,belongs_to and has_many keyword
Hi, I have two models: AdvertisementImages (table: advertisement_images) Advertisement (table: advertisements) The table advertisement_images has a foreign key to advertisements called advertisement_id. Both tables has one entry where the entry in dvertisement_images belongs to advertisement. The model code looks lik this so far: class AdvertisementImages < ActiveRecord::Base file_column
2007 Jul 05
0
act_as_tree, belongs_to and has_many foreign keys incorrect
Two models: class Project << ActiveRecord::Base has_many :files end class File << ActiveRecord::Base has_one :project acts_as_tree end Inside of the project model, when creating a new product, I want to store the hierarchy of files within it. If I do, my_top_level_file = my_project_object.files.create(:file_name => ''foo'');
2009 Jan 22
0
ActiveLdap belongs_to and has_many associations
Hi, I am trying to use ActiveLdap for authentication in my rails app. But I am running into a problem with the "belongs_to" and "has_many" associations. Here ist how my models look like. class Person < ActiveLdap::Base ldap_mapping :dn_attribute => "uid", :prefix => "ou=People", :classes =>
2005 Apr 18
1
belongs_to / has_many multiple validation errors
Hi, when using the following code in my model I get 2 errors for only 1 field. belongs_to :category validates_presence_of :title, :message => "required field missing" Then when I test the validation by creating a record without a title I''m told that the title field is missing twice. Please help as this has has me stumped for a few days now. Many Thanks Kieran
2007 Aug 02
0
Reading and saving data with belongs_to and has_many
Hi all, I''m new to Ruby on Rails, and so I have a question that''s probably simple, but I can''t figure it out. I''m trying to create several models that all belong_to a master model, say "entries", which has_one of the others. The other tables ("destinations", "people", "entrydates") all have the entry_id row. How would
2006 Mar 22
2
has_many, belongs_to
I have one table(profiles) where each row has many rows in another table(carriers). If I write profile.carriers I get a collection containing all carriers that belong to the current profile. My question is: how do I sort the collection profile.carriers? I would like to sort it on one of the columns (found in the table carriers). Can I override some method in the carrier model or somewhere
2006 Aug 01
2
has_many :through a belongs_to relationship
I have users who belong to a group. I also have a room that belongs to a group. I want to use a has_many through association to link the room and the users as such: class Room < ActiveRecord::Base belongs_to :group has_many :users, :through => :group end The SQL generated for the search is incorrect: SELECT users.* FROM users INNER JOIN group ON users.group_id = groups.id WHERE
2006 Jan 20
1
stack level too deep from has_many / belongs_to relationship
I have the following 3 models (2 models joined by an intermediate): 1. class Exercise < ActiveRecord::Base 2. has_many :routines, :class_name=>''RoutineExercise'' 3. end 1. class Routine < ActiveRecord::Base 2. has_many :exercises, 3. :class_name=>''RoutineExercise'', 4. :order=>''position'' 5. end 1. class