Skip to content

Commit

Permalink
fixed viewing nonexistent rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ethn committed Sep 28, 2011
1 parent 4c50b55 commit fb6fd20
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ def load_card!
raise Wagn::NotFound, "We don't know what card you're looking for."
when @card.known? # default case
@card

## I think what SHOULD happen here is that we render the missing view and let the Renderer decide what happens.

when params[:view]=='edit_rule'
# FIXME this is a hack so that you can view load rules that don't exist. need better approach
# (but this is not tested; please don't delete without adding a test)
@card
when requesting_ajax? || ![nil, :html].member?(params[:format]) #missing card, nonstandard request
## I think what SHOULD happen here is that we render the missing view and let the Renderer decide what happens.
raise Wagn::NotFound, "We can't find a card named #{@card.name}"
when @card.ok?(:create) # missing card, user can create
params[:card]={:name=>@card.name, :type=>params[:type]}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/card_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def index_preload
params[:id] = (System.setting('*home') || 'Home').to_url_key
end

def mine_preload() params[:id] = User.current_user.card.name end
def mine_preload() params[:id] = User.current_user.card.name.to_url_key end
def index() show end
def mine() show end

Expand Down
4 changes: 2 additions & 2 deletions packs/right/rstar_pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class Wagn::Renderer::RichHtml
ruled_card = Card[main_set_name.trunk_name]
current_rule = ruled_card.setting_card(setting_name)
current_rule.after_fetch if current_rule
current_rule_set = current_rule ? current_rule.name.trunk_name : nil
current_rule_set = current_rule ? current_rule.name.trunk_name.to_key : nil

mode, sifter = :override, {:override => [], :defer=>[]}
Wagn::Pattern.set_names(ruled_card).each do |set_name|
if [current_rule_set.to_key, params[:new_rule_set]].member? set_name.to_key
if [current_rule_set, params[:new_rule_set]].member? set_name.to_key
mode = :defer
else
sifter[mode] << set_name
Expand Down

0 comments on commit fb6fd20

Please sign in to comment.