更新#1令人驚訝的工作,如果在Firebug,我改變產生<輸入> HTML到<一個>,它按預期工作。但爲了使此解決方案永久化,我將不得不更改ActiveScaffold的代碼。「創建另一個XXX」按鈕不ActiveScaffold
更新#2現在我已經改變了ActiveScaffold的代碼。這解決了我的問題。但問題仍然沒有答案。
我有一個模型ListingMovie:
class ListingMovie
has_many :movie_shows, :dependent => :destroy
belongs_to :movie
...
...
end
和MovieShow:
class MovieShow
belongs_to :listing_movie
validates_presence_of :start_time, :end_time
end
我有管理:: ListingMoviesController:
class Manage::ListingMoviesController < Manage::BaseController
helper Mange::MovieShowsHelper
active_scaffold :listing_movie do |config|
config.columns = [:movie, :listing, :start_date, :end_date, :movie_shows]
config.columns[:listing].form_ui = :select
config.columns[:movie].form_ui = :select
end
protected
def self.active_scaffold_controller_for(klass)
return Manage::MoviesController if klass == Movie
return Mange::MovieShowsController if klass == MovieShow
end
end
和管理:: MovieShowsController
class Manage::MovieShowsController < Manage::BaseController
active_scaffold :movie_show do |config|
config.subform.columns = [:start_time, :end_time]
end
end
當我嘗試創建/更新ListingMovie時,我顯示了一個具有「創建另一個電影放映」結尾的表單。之前當我點擊它時,它發出了一個Ajax請求,並在表單底部添加了兩個新字段,讓我可以爲關聯的MovieShow指定start_time和end_time。現在,當我點擊它時,服務器沒有請求。因此新的字段不會添加到表單中。
以下是按鈕的HTML:
<input data-remote="true" href="/manage/listing_movies/edit_associated?association=movie_shows" id="as_manage__listing_movies--movie_shows-subform-create-another" style="" type="button" value="Create Another Movie show">
我無法調試這是我所看到的任何錯誤。點擊按鈕根本不會做任何事情。
需要注意的一件事是,如果我在表單中放入了一些錯誤的數據,然後嘗試「創建/更新」ListingMovie,則會使用「新」表單字段再次呈現表單以指定start_time和end_time。
我使用Rails 3.0.1和ActiveScaffold 3.0.6 謝謝!
而不是把一個'input'標籤'anchor'標籤內,我只使用'anchor'標籤。 – Waseem