Rails in Action - Privatizing Assets -


admin logged in , created ticket related project uploaded attachment correctly no errors when try download it goes false condition , when replaced can? cannot? able download asset , needed make admin able download without changing current controller show action ?

note: false condition should happen if user not have permission see assets , don't how how happen admin cant find in book. go through before ?

class filescontroller < applicationcontroller     before_filter :authenticate_user!      def show         asset = asset.find(params[:id])         if  can?(:view, asset.ticket.project)             send_file asset.asset.path, :filename => asset.asset_file_name,                                         :content_type => asset.asset_content_type         else             flash[:alert] = "the asset looking not found."             redirect_to root_path         end     end end 

ability.rb

class ability     include cancan::ability      def initialize(user)         user.permissions.each |permission|             can permission.action.to_sym, permission.thing_type.constantize |thing|                 thing.nil? || permission.thing_id.nil? || permission.thing_id == thing.id             end         end     end end 


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -