PiRSquared17 / activescaffold

Automatically exported from code.google.com/p/activescaffold
MIT License
0 stars 0 forks source link

Nested scaffold with has_many through association #738

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

there is a service->positions->invoices relation

class Service < ActiveRecord::Base
  has_many :positions, :order => "start_date"
  has_many :invoices, :through => :positions, :order => "invoices.date, invoices.id"
...
class Invoice < ActiveRecord::Base
  has_many :positions, :dependent => :destroy
  has_many :services, :through => :positions
...
class Position < ActiveRecord::Base
  belongs_to :service
  belongs_to :invoice
...

And following controllers setup:

class ServicesController < ApplicationController
  active_scaffold do |config|
    config.columns = [:customer, :name, :amount, :default_units, :default_rebate, :period, :start_date, :end_date, :invoiced_to]
    config.create.columns.exclude :invoiced_to
    config.update.columns.exclude :invoiced_to
    config.columns[:invoiced_to].includes = [:positions, :invoices]
    config.nested.add_link("Invoices", [:positions])
  end
...

class InvoicesController < ApplicationController

  before_filter :fix_as_config

  active_scaffold do |config|
    config.actions.exclude :show
    config.columns.exclude :services
    config.columns = [:created_at, :number, :date, :customer, :positions, :total, :status]
    config.create.columns.exclude :total
    config.update.columns.exclude :total
  end
...

class PositionsController < ApplicationController
  active_scaffold do |config|
    config.columns = [:invoice, :service, :start_date, :end_date, :amount, :units, :rebate]
    config.create.columns.exclude :invoice
    config.update.columns.exclude :invoice
  end
...

What is the expected output? What do you see instead?

When I go to see Invoices link (which shows positions scaffold) and then go to 
Invoice->New form I see no field for service input. It was for sure dropped 
when creating nested scaffold before (as the parent for it was a service). 
Field is shown after app restart when no nested positions are shown before.
Solution to this problem was disabling class caching but it slows things down :(

What version (or revision) of the product are you using?
2.3 branch with 2.3.5 rails

Original issue reported on code.google.com by Krzyszto...@gmail.com on 19 Mar 2010 at 9:53

GoogleCodeExporter commented 9 years ago
If you open a nested positions scaffolds from services controller, you will get 
a
constraint for the selected service, so that field is not shown and it will be
filled with that constraint.

Original comment by sergio.c...@gmail.com on 22 Mar 2010 at 3:00

GoogleCodeExporter commented 9 years ago
No no no Sergio - it is once visible and once not depending on the order of 
pages 
generated - what you have written is correct for positions accessed from a 
service - 
but just afterward there is no service field in new invoice form (unless class 
caching 
is turned off) :(

Original comment by Krzyszto...@gmail.com on 22 Mar 2010 at 7:20

GoogleCodeExporter commented 9 years ago
Sorry, I can't understand how to reproduce it, can you describe it step by step?

Original comment by sergio.c...@gmail.com on 23 Mar 2010 at 8:19

GoogleCodeExporter commented 9 years ago

Original comment by sergio.c...@gmail.com on 30 Mar 2010 at 1:38

GoogleCodeExporter commented 9 years ago

Original comment by sergio.c...@gmail.com on 12 Apr 2010 at 7:58

GoogleCodeExporter commented 9 years ago

Original comment by sergio.c...@gmail.com on 5 Jul 2010 at 7:39