similar to: Saving ActiveRecord objects that are composed of other objects

Displaying 20 results from an estimated 20000 matches similar to: "Saving ActiveRecord objects that are composed of other objects"

2006 Oct 03
0
WebObjects-style Object Cache
Hey Guys, Here''s the scenario: I have a model Page and every page has multiple page_parts. So, there''s a form for editing a Page and all of it''s parts and when you submit the form all of your changes are saved. There''s an action that handles the post that saves the page and all the parts. def handle_post if request.post? @page.attributes =
2006 Jul 31
2
Testing the flash.now
What''s the best way to test the flash when you use flash#now ? For example, if I set the flash in my controller: flash.now[:notice] = ''This will only show up on this action.'' How do I test it? Normally I would do: assert_equal ''This will only show up on this action.'', flash[:notice] But this doesn''t seem to work with flash.now. Any
2006 Dec 05
1
has_many :through questions
I have a database with 4 tables Months has_many :weeks Weeks has_many :days Days has_many :hours Hours Weeks belong_to :month Days belong_to :week hours belong_to :day I need to access the month_id in the Hour.rb model. find(:first, :conditions => ["user_id = ? AND month_id = ?", user_id, month_id]) Thanks -- Posted via http://www.ruby-forum.com/.
2006 Apr 17
7
MySQL backticks and column names
The upgrade to Rails 1.1 hurt my ability to run tests because it generated the following MySQL error: Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''key ON config (key)'' at line 1: CREATE UNIQUE INDEX key ON config (key) I have a table called `config` with a column
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)
2007 Sep 24
1
IE memory leak and update()
Hello I have following code in my project and it''s a question for me if it causes memory leaks in IE. pagePart = getSearchResult(); // retrieve part of the page w/ search result from server $(''container'').update(pagePart); $$(''#container a'').each(function(a) { Event.observe(a, ''click'', ...); // handlers for link clicks }); As you
2006 May 01
17
Radiant CMS
I am pleased to announce that Radiant CMS is now publically available from the Subversion repository at: http://radiantcms.org/ What is Radiant? ---------------- Radiant is a no-fluff, open source content management system designed for small teams. It is similar to Textpattern or MovableType, but is a general purpose content management system (not a blogging engine). Radiant features:
2006 May 01
1
Radius 0.0.1 -- Powerful Tag-Based Templates
I am pleased to announce the immediate release of Radius 0.5.0. Radius is a small, but powerful tag-based template language for Ruby inspired by the template languages used in MovableType <www.movabletype.org> and TextPattern <www.textpattern.com>. It uses tags similar to XML, but can be used to generate any form of plain text (HTML, e-mail, etc...). This release is much more feature
2012 Jan 27
3
How to test the model dependence ?
Good morning, I''m new to rails and am having some basic questions in development. See if anyone can help me with a test problem. I need to test if my model "Procedure" is linked to the workflow. If not, the system must acknowledge an error. Below is the code that is in the file test \ unit \ procedure_test.rb. require ''test_helper'' class ProcedureTest <
2006 Apr 25
3
Creating your own generators
So I''m interested in creating an application specific generator. The script/generate command tells me that all I have to do is put a generator in my rails_root/generators: > 2. Unzip to directory /Users/{username}/.rails/generators/login > to use the generator with all your Rails apps > or to {app_root}/generators/login > to use with this app only. So I
2008 Jul 29
0
cannot destroy child records
Hi, i am lost here, i have these models: class Shift < ActiveRecord::Base has_many :transactions,:dependent => :destroy has_one :exchangeproposal class Transaction < ActiveRecord::Base belongs_to :shift has_many :exchangeproposals class Exchangeproposal < ActiveRecord::Base belongs_to :shift belongs_to :transaction with these models i can''t destroy an
2007 Oct 16
10
Scenarios Plugin Pre-Announcement
This is sort of a pre-announcement for a Rails plugin my friend Adam Williams and I are working on. We''re in the process of extracting it from a project we are working on so that it can be generally useful to the Rails community. We are calling it "Scenarios". It is a drop in replacement for Rails fixtures: http://faithfulcode.rubyforge.org/svn/plugins/trunk/scenarios/README
2006 Jan 12
2
Can A Model Have Many belongs_to?
I am very new to Rails. After skimming through the documentation over the last several days, I''m struggling with the appropriate use of belongs_to. My main question is whether a model can have several belongs_to declarations. I have not seen any examples online show that usage. If it can, then I would like to know if it''s poor form or what the best practices are around
2020 Jul 06
1
systemd environment var composed of vars
Is it somehow possible to use composed ENV vars in a systemd unit file? Simple example, env file has ADDRESS=foo PORT=bar LISTEN=${ADDRESS}:${PORT} putting ${ADDRESS}:${PORT} directly in the unit file works, $LISTEN not. Does systemd supports such var substitution? -- Leon
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 Apr 08
4
saving related objects using has_many_through associations
This only saves the @person but not the @address. Shouldn''t it save both? @person = Person.new(params[:person]) @address = Address.new(params[:address]) @person.address << @address @person.save here is what I have: class Person < ActiveRecord::Base has_many :addressables has_many :addresses, :through => :addressables end class Address <
2006 May 03
2
Perplexing nested transaction issue
I''ve been struggling with a strange nested transaction problem for a while. I have a two objects with the following relationships: Mail has_many :recipients Recipients belong_to :mail I''d like to update the status of the Mail object while sending mails for each of it''s recipients. Following is a simplified example that I''m having problems with: def
2006 Mar 16
4
Table Relationships Problems.
I have the following tables setup: locations :id :name systemmessages :id :name systemmessage_validtimes :id :name :systemmessage_id :location_id :start :end The systemmessage_validtimes has a ''has_many'' relationship with systemmessages, meaning that there could be many valid times for each system message. @systemMessage = Systemmessage.find(1) E.g. I
2006 Feb 28
1
adding to errors in controller?
def update @product = Product.find(params[:id]) @product.attributes = params[:product] if params[:main_image] image = Image.new params[:main_image] if image.save @product.main_image.destroy if @product.main_image @product.main_image = image else @product.errors.add_to_base(image.errors.full_messages.join(", ")) end end
2008 Sep 18
1
"xxx_id may not be null" when saving many to many joined objects
Hi, I have two model classes; Tune and Title and they are joined in a many to many relationship through a Variation class. Here''s some stub code of the models: class Tune < ActiveRecord::Base has_many :variations, :dependent => :destroy has_many :titles, :through => :variations ... class Title < ActiveRecord::Base has_many :variations, :dependent => :destroy