similar to: Two unsaved related objects

Displaying 20 results from an estimated 1000 matches similar to: "Two unsaved related objects"

2006 Mar 13
2
relationship woes
I have two tables: class PgmUpdate < ActiveRecord::Base has_many :pgm_visits, :foreign_key => ''pgm_update_fk'' ... and class PgmVisit < ActiveRecord::Base belongs_to :pgm_update, :foreign_key => ''pgm_update_fk'', :dependent => true ... According to the has_many docs (http://api.rubyonrails.org/classes/
2006 Mar 17
2
Temporary Model Data
I am trying to optimize some methods in my model so they don''t repeat CPU intensive algorithms every time I call the method in the same request/response cycle. Eg. ================ def invitations all_pgm_updates.find_all do |update| update.invited? end end ================ I want to do something like: ================ def invitations if @invitations.nil?
2006 May 22
1
Model Modules, Dev vs Prod
I have a pretty complex model with many modules and I have been trying to keep it clean, but I find that loading the model in development mode using WebBrick is much more lenient than production mode with lighttpd/fcgi. For instance, if I neglect to create a dedicated file that declares the module then I run everything in development mode it works fine, but as soon as it is deployed I
2006 Apr 18
1
Shared model with Capistrano/SVN
I got Capistrano working with one of my Rails projects, but I intend to use identical models in a second project. I originally was using a symlink to point to the other models, but I want to be able to use the same ''rake deploy'' command for the two apps individually so I don''t have to deploy both together all the time. Any ideas? -John -- John Smilanick
2006 Mar 30
1
strange has_many array problem
I have a class that has_many :visits, I want to search through the visits to get only ones that are committed: I thought it would be as easy as: ================== visits.find_all do |visit| visit.coming? end ================= but this always returns the entire list of visits. The only way to get it to work is to put the visits into a new array first: =================
2006 Mar 14
1
Where to validate?
class PgmUpdate < ActiveRecord::Base has_many :pgm_visits ... class PgmVisit < ActiveRecord::Base belongs_to :pgm_update ... I am trying to make sure that none of the visits in PgmUpdate overlap start and end dates. Should this validation exist in PgmUpdate or the controller? It seems natural to put them in PgmUpdate, but I must force the relationship together because
2006 Mar 14
8
email address parse
hi all how to parse such email string to a array: #-------------------------------------------- "joe black"<joe_1@joe_black.com> joe_2@joe_black.com, joe_3@joe_black.com #-------------------------------------------- seems emails from user input include various format. and i have to split them to a array. any idea? regards. -- Posted via http://www.ruby-forum.com/.
2006 Apr 18
1
NoMemoryError
I am using the Openbase adapter and have had a similar glitch here and there, but after I go into production I consistently get an error on one page. ActionView::TemplateError (NoMemoryError: failed to allocate memory: SELECT * FROM ... I cannot track down the exact location of the error, but the production log says it was around:
2006 Mar 14
7
Overriding new or create for a model
I have a model where I need to calculate one of the fields when I create a new instance. It seems to me that I should do this in the model code and that I should override the new and/or create methods. Is this the right approach and, if so, how can I execute the existing method but add on my calculation? I want something like: def create -Do the original create first- field =
2006 Mar 14
3
Help doing find - look for nonempty habtm
I''ve got a Cuisine and a Restaurant model, with a habtm. One thing I want to do is find all the cuisines that have at least one restaurant associated with them. Right now I''m using the following SQL query: SELECT DISTINCT(cuisines.*) FROM cuisines, restaurants, cuisines_restaurants WHERE cuisines.id = cuisines_restaurants.cuisine_id AND restaurants.id =
2006 Mar 22
9
Display problem
hey guys, Does anyone know why the french letter "?" is displayed as a question mark "?" inside an <h1> tag ? -- Posted via http://www.ruby-forum.com/.
2006 Mar 29
3
Grouping Controllers into Modules - Doesn''t work!?
Ok, what I want to achieve is: http://<mydomain>/admin/products calls app/controllers/admin/products_controller.rb According to Agile Development with Rails this should work. I executed the follwing commands: rails myproj cd myproj script/generate controller Admin script/generate scaffold Admin::Product this creates app/controllers/admin/products_controller.rb all the views &
2006 Jan 16
3
routing to controller inside module
Hey, am i to stupid to find the information about how to route to a controller in a module? Maybe module support has gone! The controller is under: app/controllers/admin/my_controller.rb The my_controller.rb file looks like this: module Admin class MyController def index render :text => ''Hello!'' end end end How does a route to all controllers under module
2006 Feb 22
9
acts_as_habtm_list plugin
I''d like to announce acts_as_habtm_list plugin for rails. acts_as_habtm_list is a Ruby on Rails plugin, that can manage ordered lists through a join-table. It is providing almost the same Api as acts_as_list. The position column has to be defined in the join table. You can find additional information at: http://www.inlet-media.de/acts_as_habtm_list/ Install it executing this command
2006 Mar 28
8
1.1 broke my app
I upgraded to Rails 1.1 (ruby 1.8.2 and ruby 1.8.4 on RHEL 4 using webrick or fastcgi) and all of a sudden I get this hitting a controller: wrong number of arguments (1 for 0) RAILS_ROOT: script/../config/.. Application Trace | Framework Trace | Full Trace /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:379:in
2006 Mar 21
8
Redirect without port number?
On my host I run my lighttpd instance bound to a specific port and my hostname is mapped to this port (I''m not exactly sure how this is accomplished, but it is lighttpd also listening on port 80 which handles this for me I believe). A redirect from rails includes my local port number in the request, so that it shows up in the address bar. I prefer people not to see this - I
2006 Mar 14
3
Check whether externam URL is valid?
Hey, I have users entering URLs into my app, is there anyway in which I can check to see if the URLs actually point to something before saving the user input? Maybe a kind of ''ping''-action that returns true on success? (btw: does anyone of a tentative release date for Rails1.1? I''ve been slobbering all over my RailsRecipes book and I can''t wait! Also, Scott
2006 Mar 15
4
help with DRY violation
I''m trying to be a good rails developer and fix DRY violations as i find them. However, i''m trying to fix this one, i cant seem to get it to work. I have two tables A and B that have a one-to-one relationship. Table B belongs_to Table A. Table A has_one Table B. I''m creating instances of Table A in different places, depending on the controller. However, for each
2006 Mar 04
4
Submitting data to two different tables with two different models
I''m very new to Rails. I''ve been reading Agile Web Dev for a while and read up on ruby, but I''m still learning. I designed a website for someone for an engineering shop. New projects had to be added manually. Well, I figured this would be a great canidate for railifying! I have the form working perfectly, you can add your data and get it in a table, and listing
2006 Mar 08
3
List and update values from text_field_tag fields
Hi, I populate a couple of text_field_tag''s with data from an AciveRecord object. Some fields are editable and at the end of the page there''s a submit button. I want the new values to be updated in the DB but by default my original values are stored again. How do i go about doing this? thanks/jens AIM: jens.tinfors@mac.com Skype: jtinfors