Skip to content

Commit

Permalink
redirect_after_submit now hunts further for an owning model. [#449 st…
Browse files Browse the repository at this point in the history
…ate:resolved]
  • Loading branch information
bryanlarsen committed Oct 21, 2009
1 parent e7f9dea commit e118cd0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hobo/lib/hobo/model_controller.rb
Expand Up @@ -383,14 +383,19 @@ def destination_after_submit(record=this, destroyed=false)
(!destroyed && object_url(@this)) ||

# Then the show page of the 'owning' object if there is one
(@this.class.default_dependent_on && object_url(@this.send(@this.class.default_dependent_on))) ||
object_url(owning_object) ||

# Last try - the index page for this model
object_url(@this.class) ||

# Give up
home_page
end

def owning_object
method = @this.class.dependent_on.detect {|m| !@this.send(m).nil?}
method ? @this.send(method) : nil
end


def url_for_page_path
Expand Down

0 comments on commit e118cd0

Please sign in to comment.