Skip to content

Commit

Permalink
Rapid -- fix user-changer to work with login, not name
Browse files Browse the repository at this point in the history
  • Loading branch information
tslocke committed Jul 4, 2008
1 parent bca239a commit 33bb46b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions hobo/lib/hobo/dev_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ class Hobo::DevController < ActionController::Base
hobo_controller

before_filter :developer_modes_only

def set_current_user
model = params[:model] || Hobo::User.default_user_model
self.current_user = params[:name] ? model.named(params[:name]) : model.find(params[:id])
self.current_user = if params[:login]
model.find(:first, :conditions => {model.login_attribute => params[:login]})
else
model.find(params[:id])
end
redirect_to(request.env["HTTP_REFERER"] ? :back : home_page)
end

Expand Down
2 changes: 1 addition & 1 deletion hobo/taglibs/rapid_navigation.dryml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ but rather write your own navigation using the `<navigation>` tag -->
<set user="&Hobo::User.default_user_model"/>
<select-menu if="&user && RAILS_ENV == 'development'"
first-option="Guest" options="&user.all(:limit => 10).*.login"
onchange="location.href = '/dev/set_current_user?name=' + this.options[this.selectedIndex].value"
onchange="location.href = '/dev/set_current_user?login=' + this.options[this.selectedIndex].value"
selected="#{current_user.login}"
class="dev-user-changer"/>
</def>

0 comments on commit 33bb46b

Please sign in to comment.