ruby - how to ensure that a user can not redirect to another element in the child engine from within the parent engine -


i have engines mounted inside engines engine made congregation of multiple child elements various engines. engine mounted in main app. routes follows:

rails.application.routes.draw    namespace :parent_engine, :path  => "/foo"     match "/", :to=>"parent_engine#index"      resources :parent_engine , :only=>[:show]       mount engine1::engine => '/engine1'       mount engine2::engine => '/engine2'     end   end end 

now when wish see element "engine1" have url

/parent_engine/:id/engine1/object_type/:id 

the trouble facing need stop user being able access object of engine1 explicitly updating url in browser. eg:

from:

/parent_engine/1/engine1/object_type/1 

to:

/parent_engine/2/engine1/object_type/2 

also can not put check in mounted engines these mounted seperately in container app well. dont want user able able redirect object instance when inside context of parent engine.

thanks , regards in advance.

i'm not sure try do, suspect may able use route constraints:

rails.application.routes.draw    namespace :parent_engine, :path  => "/foo"     match "/", :to=>"parent_engine#index"      resources :parent_engine , :only=>[:show]       mount engine1::engine => '/engine1', :constraints => engine1contraint.new       mount engine2::engine => '/engine2'     end   end end 

then can define config/initializers/engine1_contraints.rb with

class engine1contraint   def matches?(request)     request.path != 'something' || request.env['warden'].user == 'admin'   end end 

or whatever rules need adjust there, mother engine control on child engines.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -