Skip to content

Instantly share code, notes, and snippets.

@rubypirate
Created October 25, 2010 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubypirate/645306 to your computer and use it in GitHub Desktop.
Save rubypirate/645306 to your computer and use it in GitHub Desktop.
dude
def make_front
object = params[:model].constantize.find(params[:id])
if current_user.admin?
if object.front_page == true || object.front_page == false
front_page = (object.front_page? ? false : true)
object.update_attribute('front_page', front_page)
render :partial => "make_front", :locals => { :object => object, :message => nil }
else
render :partial => "make_front", :locals => { :message => 'can not be set to front-page' }
end
else
render :partial => "make_front", :locals => { :message => 'only Jamal can do this action' }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment