[Rails] Edit With Nested Forms - Values Not Preserved Across Submit

2011-03-25 Thread MaggotChild
When a nested form submitted to the create action contains missing data, the form is redisplayed and the nested values the user entered remain. When submitting the same nested form to the update action, the newly entered values remain for the parent record, but the child records revert back to

[Rails] Re: Edit With Nested Forms - Values Not Preserved Across Submit

2011-03-25 Thread MaggotChild
On Mar 25, 12:07 am, MaggotChild hsomob1...@yahoo.com wrote: Is it possible to retain nested data across form redisplays to the update action? Anyone? The answer appears to be no, given the Rails Guides example and the Complex Forms Examples: github.com/alloy/complex-form-examples/tarball

[Rails] Rails Strives For DRY. A Lot of REST Routes, Not So DRY.

2010-08-02 Thread MaggotChild
Most in the Rails community seem stick with 1 controller per resource when using RESTfull routes. This makes sense for a resource with one scope and one view, but once a resource is used with multiple scopes and/or views the amount of code duplication needed to manage these in a single controller

[Rails] Users Uploading Files To An asset_host

2010-05-01 Thread MaggotChild
I'm curious how people put static files uploaded by users to their asset host. I'd think (for non S3, CloudFiles, etc...) that the files would be submitted to the app server which would save them to a shared drive on the asset host. I've head bad things about NFS and high volume sites. Is Samba

[Rails] HABTM collection_ids: confirm changes before saving

2009-12-31 Thread MaggotChild
It seems that when a HABTM (or has many) is involved, having a confirmation page prior to saving doesn't work as seamlessly as other Rails view/model parings, specifically when confirming an edit. This is caused by the immediate inserts or deletes that take place upon assigning to collection_ids.

[Rails] Re: HABTM collection_ids: confirm changes before saving

2009-12-31 Thread MaggotChild
On Dec 31, 11:08 am, MaggotChild hsomob1...@yahoo.com wrote: def preview   @product = Product.find params[:id]   @product.attributes = params[:product]  #no product I meant that no provider_ids are included in params -- You received this message because you are subscribed to the Google

[Rails] Using current_page? With An Edit Route

2009-12-28 Thread MaggotChild
current_page?(:action = 'edit', :controller = 'admin/products') fails with an ActionView::TemplateError (No route matches ...) unless I'm in the edit action or I provide the :id. Route: /admin/products/:id/edit(.:format) {:action = 'edit', :controller = 'admin/products'} I understand why this

[Rails] db:test:purge And osql: What Happened?

2009-12-03 Thread MaggotChild
I thought I had read somewhere why db:test:purge continues to use `osql` but all I could find is this: http://dev.rubyonrails.org/ticket/7054 Obviously this never made its way into Rails. Why? What are people doing for MS SQL testing on non Windows OS'? Everyone's hacking their own workaround?

[Rails] Has Many Relationship: collection_ids= Method Useless?

2009-11-14 Thread MaggotChild
When modifying a model that has a has_one or has_many relationship people usually create form that will submit the id of the selected associated object. Rails takes this into consideration with validations: validate_presence_of :country will validate if country or country_id has been set. In

[Rails] Re: Has Many Relationship: collection_ids= Method Useless?

2009-11-14 Thread MaggotChild
On Nov 14, 2:42 am, Leonardo Mateo leonardoma...@gmail.com wrote: On Sat, Nov 14, 2009 at 6:37 AM, MaggotChild hsomob1...@yahoo.com wrote: In Rails, providing the associated ID works fine with has_one but if you try to do this with a has_many: form_for(@country) do |form|  form.select

[Rails] Nested Attributes For HABTM - Deleting The Right Record

2009-10-24 Thread MaggotChild
In a many-to-many relationship, defined via has_and_belongs_to_many, accepts_nested_attributes_for deletes the wrong record(s) when marked_for_destruction? == true. For example: class Ho AR has_and_belongs_to_many :strolls, :join_table = :ho_strolls accepts_nested_attributes_for :strolls,

[Rails] Re: Select Option Broken on Eager Load With 2nd Order Association

2009-10-15 Thread MaggotChild
On Oct 15, 12:22 am, Frederick Cheung frederick.che...@gmail.com wrote: On Oct 15, 3:13 am, MaggotChild hsomob1...@yahoo.com wrote: dont_select_me is included. The docs say nothing of about :select being stepped on by fall back left joins (not the :include!). This seems like a bug Well

[Rails] Select Option Broken on Eager Load With 2nd Order Association

2009-10-14 Thread MaggotChild
I only want to select certain columns when eager loading an association: class Package ActiveRecord::Base has_many :deliveries, :select='id, name, region_id, package_id', #exclude text column dont_select_me :include=:region end class Delivery ActiveRecord::Base

[Rails] Re: Eager Loading a Relationship That Has No PK/FK

2009-10-09 Thread MaggotChild
On Oct 8, 4:25 pm, Frederick Cheung frederick.che...@gmail.com wrote: On Oct 9, 12:01 am, MaggotChild hsomob1...@yahoo.com wrote: A Segment is linked to Media by Media.name, which is the result of concatenating Segment.name and Segment.part. As I said there are is no PK/PK relation so

[Rails] Re: Eager Loading a Relationship That Has No PK/FK

2009-10-09 Thread MaggotChild
On Oct 9, 10:24 am, Marnen Laibow-Koser rails-mailing-l...@andreas- s.net wrote: MaggotChild wrote: I'm attempting to wrestle an old DB into Rails. This relationship is giving me trouble: class Show AR::Base   has_many :segments end class Segment AR::Base   belongs_to :show

[Rails] Eager Loading a Relationship That Has No PK/FK

2009-10-08 Thread MaggotChild
I'm attempting to wrestle an old DB into Rails. This relationship is giving me trouble: class Show AR::Base has_many :segments end class Segment AR::Base belongs_to :show has_one :media #this has no PK/FK relation end A Segment is linked to Media by Media.name, which is the result of

[Rails] Running Unit Tests With SphinxSE

2009-09-26 Thread MaggotChild
Several of my unit tests run queries against SphinxSE. Since Rails creates the test DB by dumping the dev DB schema, my SphinxSE queries aren't run against the test DB. There seems to be no way to hook into the test:clone_structure task, so I thought that I'll just have the appropriate unit

[Rails] Re: Overriding AR read/write_attribute - Overridden write_attribute Is Never Called

2009-09-24 Thread MaggotChild
On Sep 24, 12:34 am, Frederick Cheung frederick.che...@gmail.com wrote: On Sep 23, 11:27 pm, MaggotChild hsomob1...@yahoo.com wrote: Could someone explain this? At a quick glance it is probably because after AttributeMethods is included in ActiveRecord::Base, write_attribute is aliased

[Rails] Re: Overriding AR read/write_attribute - Overridden write_attribute Is Never Called

2009-09-24 Thread MaggotChild
On Sep 24, 5:40 pm, MaggotChild hsomob1...@yahoo.com wrote: write_attribute is at the top of the call stack so I'd think it's going to use the most recent definition. Unless some other module redefined write_attribute within the scope of active AR::Base (as apposed to including it via

[Rails] Overriding AR read/write_attribute - Overridden write_attribute Is Never Called

2009-09-23 Thread MaggotChild
Could someone explain this? #config/initializers/ar_attributes.rb module ActiveRecord module AttributeMethods alias_method :ar_read_attribute, :read_attribute def read_attribute(attr_name) p read_override ar_read_attribute(attr_name) end alias_method

[Rails] Re: App Setting, Where To Put: environment.rb, initializer.rb, lib..?

2009-09-22 Thread MaggotChild
Thanks! --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to

[Rails] App Setting, Where To Put: environment.rb, initializer.rb, lib..?

2009-09-21 Thread MaggotChild
I have a path that my model (Audio) uses to r/w files. This path differs between production, test, and dev. Audio includes a module that overrides some ActiveRecord methods. This module is contained in config/initializers. I'd like to set the Audio directory based on my environment, but using

[Rails] Routes With Same URL Mapped To Different Actions

2009-09-09 Thread MaggotChild
Can't find the answer to this. My old message received no responses (subject was messed up). Is it possible to create routes that have the same URL yet map to a different action based on the HTTP method (or pseudo method) like a Rails' resource? For example: map.resources :foo, :collection = {

[Rails] Custom Routes: Determining Action Named Based On Method

2009-09-08 Thread MaggotChild
Is it possible to create routes that have the same URL yet map to a different action based on the HTTP method (or pseudo method)? For example: map.resources :foo, :collection = { :purge = :get, :purge_them = :post } I'd like to use /foo/purge for both actions, and have the appropriate

[Rails] HTTP Auth 401 Even on Valid Login

2009-05-03 Thread MaggotChild
I can't understand why authenticate_or_request_with_http_basic keeps failing even though I am entering the correct info. If I try to access /admin/items/new, I enter the correct info but I keep getting prompted. The strange part is that when I cancel out, I get HTTP Basic: Acce. Here's the

[Rails] Overriding a Relationships Propertry

2009-04-26 Thread MaggotChild
I have a child relationship that is denormalized. I want to normalize it at the object level once it's retrieved: class Parent has_many :denormalized_children, :class_name='Child' def children if @normalized_children.nil? @normalized_children = []

[Rails] Creating/Updating Models from text/xml Requests

2009-03-13 Thread MaggotChild
I'm curious how others would deal with this situation. In my case, I have: class Package has_many :deliveries end class Delivery belongs_to :package belongs_to :region end class Region has_many :deliveries end And accept XML requests in the following manner: package nameGood

[Rails] Re: Multiple foreign keys create / destroy

2009-03-08 Thread MaggotChild
class House ActiveRecord::Base     belongs_to :country     belongs_to :cities     belongs_to :streets end Now...if i want to create a house like this: @street = Street.find(1) @house = @street.houses.new @house.name = Burlington house @house.save Now...only the street_id key is

[Rails] Collection of Partials, :as Option No Good, TemplateError

2009-02-24 Thread MaggotChild
I'm trying to render a collection of partials using :as. It raises an undefined local variable exception. Not sure why: ~/delivery-log/app/views/packages $ ls -1 _package.html.erb _package_list.html.erb index.html.erb index.html.erb: %= render :partial='package_list', :collection=@packages,

[Rails] Re: Collection of Partials, :as Option No Good, TemplateError

2009-02-24 Thread MaggotChild
On Feb 24, 11:54 am, Eric ericgh...@gmail.com wrote: On Feb 24, 11:13 am, MaggotChild hsomob1...@yahoo.com wrote: I'm trying to render a collection of partials using :as. It raises an undefined local variable exception. Not sure why: Why not use :locals = ? Sure there a workarounds

[Rails] Re: ActiveRecord Unexplainable SystemStackError - Only in WEBrick

2009-02-05 Thread MaggotChild
On Feb 3, 2:18 pm, Frederick Cheung frederick.che...@gmail.com wrote: On Feb 3, 7:33 pm, MaggotChild hsomob1...@yahoo.com wrote: On Feb 2, 2:54 pm, Frederick Cheung frederick.che...@gmail.com Does it only happen when class caches is false ? Why yes Fredrick, it does. That pretty much

[Rails] Re: ActiveRecord Unexplainable SystemStackError - Only in WEBrick

2009-02-05 Thread MaggotChild
On Feb 3, 7:20 pm, Alan Brown stre...@gmail.com wrote: So how is the conditions clause built.  can you log it before passing it to find? Yes I can see the clause in the development log. The query is valid, it executes fine. It's when the Delivery class is assembled by ActiveRecord that the

[Rails] Re: ActiveRecord Unexplainable SystemStackError - Only in WEBrick

2009-02-03 Thread MaggotChild
On Feb 2, 2:54 pm, Frederick Cheung frederick.che...@gmail.com wrote: On Feb 2, 1:33 pm, Ryan Bigg radarliste...@gmail.com wrote: Why not use a search plugin like thinking sphinx to do your searching for you? Overkill. The searching is rudimentary so I just quickly created something.

[Rails] ActiveRecord Unexplainable SystemStackError - Only in WEBrick

2009-02-02 Thread MaggotChild
This SystemStackError is driving me crazy. It only takes place when testing with WEBrick - I can't reproduce it with any tests. It is caused by calling the missing id method (base.rb:2435) on my ActiveRecord class. WEBrick and my tests are running as the same user, with a `ulimit -s` of 10240.

[Rails] Re: ActiveRecord Unexplainable SystemStackError - Only in WEBrick

2009-02-02 Thread MaggotChild
On Feb 2, 1:33 pm, Ryan Bigg radarliste...@gmail.com wrote: Why not use a search plugin like thinking sphinx to do your searching for you? Overkill. The searching is rudimentary so I just quickly created something. In any case, I take it you had no thoughts as to why I'm receiving the stack

[Rails] Route Collections and HTTP methods

2009-01-30 Thread MaggotChild
I don't see a way to create a single URL in a collection and then have routing dispatch to the appropriate method based on the HTTP method. map.resources :packages, :collection={ :search=:get } Gets me half way there, but I can see a way to say that I want the POST to go to the do_search

[Rails] Re: Route Collections and HTTP methods

2009-01-30 Thread MaggotChild
..but in general searches are GET and never POST. I don't know where this nonsense comes from but it's breaking the principles behind the HTTP. Well I don't disagree with this paradigm, but the point is Rails seems to not allow one to set up a route like the defaults provided by

[Rails] url_for, routes, and the current url

2009-01-11 Thread MaggotChild
I need to generate 2 types of URL and have defined my routes as: map.country_yes /:country/ yes, :controller=posts, :action=country, :yes=true map.country_no /:country/ no, :controller=posts, :action=country, :yes=false map.yes /yes, :controller=posts, :action=index, :yes=true map.no /no,