|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Only One Controller + UrgentHi Champs, Need Help .. :( Actually the thing is that i am having many controllers a, b, c and d.. But what i want it that only "a" should be displayed to the users .. b, c, d not .. Is there any way to do it .. ? Cheers .. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@... To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Only One Controller + UrgentHello,
I think you can add a before_filter in your application_controller so that it prevents the display when params[:controller] is not a. Hope it helps ! Cyril. 2009/7/9 Hemant Bhargava <rails-mailing-list@...>
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@... To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Only One Controller + UrgentHemant Bhargava wrote: > Hi Champs, > > Need Help .. :( > > Actually the thing is that i am having many controllers a, b, c and d.. > But what i want it that only "a" should be displayed to the users .. b, > c, d not .. > Is there any way to do it .. ? > > Cheers .. Yes, you can do this a couple of ways.. The first way is you can inhibit the routing of controllers you don't want people to access by doing something similar: Remove the routing to that controller completely OR map.resources :controller_name, :only => :method_name You could setup a catchall method using the above and have it redirect to some other controller etc... OR Place the following at the top of your controllers: class YourController < ApplicationController before_filter :login_required, :authorize ... end .. which will force them to login and then it will call an authorize function to check if they are an admin role.. Place the following in application_controller.rb private def authorize unless logged_in? && User.find(current_user).admin? redirect_to root_url end end .. and create an admin role on your users table -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@... To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Only One Controller + UrgentOR, like was mentioned above Create any method that checks for what conditions you are specifying to access that controller through a before_filter My authorize example works great for users but you may or may not have a users database setup. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@... To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Only One Controller + UrgentWhat is the first step you are describing here .. ? i did not get it properly .. ? Älphä Blüë wrote: > Hemant Bhargava wrote: >> Hi Champs, >> >> Need Help .. :( >> >> Actually the thing is that i am having many controllers a, b, c and d.. >> But what i want it that only "a" should be displayed to the users .. b, >> c, d not .. >> Is there any way to do it .. ? >> >> Cheers .. > > Yes, you can do this a couple of ways.. > > The first way is you can inhibit the routing of controllers you don't > want people to access by doing something similar: > In Which controller or config/routes.rb file .. > Remove the routing to that controller completely OR > map.resources :controller_name, :only => :method_name > > You could setup a catchall method using the above and have it redirect > to some other controller etc... > > OR -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@... To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Only One Controller + UrgentFirst, how are you creating these controllers? Are you creating them RESTfully? Are you using generate controller or generate scaffold? If you are generating via scaffold then inside your routes.rb file you'll see something like: map.resources :controller Mapping is what creates the routes for this. Keep in mind that at the bottom of that file you may have: map.connect ':controller/:action/:id' map.connect ':controller/action/id.:format' These two lines basically setup the controller, action, id routing to every controller you create. If you don't want these to manage those routes you need to comment them out: # map.connect ':controller/:action/:id' # map.connect ':controller/action/id.:format' Then, you setup explicit routing using the examples I gave. If you are having trouble with routes then you need to research them a bit and get familiar with them. They are very important for working with rails: http://guides.rubyonrails.org/routing.html -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@... To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Only One Controller + UrgentThanks a lot to all of you .. Really Helpful .. Cheers .. Älphä Blüë wrote: > First, how are you creating these controllers? Are you creating them > RESTfully? Are you using generate controller or generate scaffold? > > If you are generating via scaffold then inside your routes.rb file > you'll see something like: > > map.resources :controller > > Mapping is what creates the routes for this. Keep in mind that at the > bottom of that file you may have: > > map.connect ':controller/:action/:id' > map.connect ':controller/action/id.:format' > > These two lines basically setup the controller, action, id routing to > every controller you create. If you don't want these to manage those > routes you need to comment them out: > > # map.connect ':controller/:action/:id' > # map.connect ':controller/action/id.:format' Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@... To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Only One Controller + UrgentCan i do this thing in config/routes.rb ..? If yes .. How can i .. ? Hemant Bhargava wrote: > Thanks a lot to all of you .. > Really Helpful .. > > Cheers .. > > Älphä Blüë wrote: >> First, how are you creating these controllers? Are you creating them >> RESTfully? Are you using generate controller or generate scaffold? >> >> If you are generating via scaffold then inside your routes.rb file >> you'll see something like: >> >> map.resources :controller Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@... To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Only One Controller + Urgentquite interesting problem I think best way to add :before_filter to your controllers routing will restrict even the admin level user to access the controllers. if you want to restrict all users including the admin then you have to think how can you access that controller from the internal system (because if you are using restful routing and have not define anything for that controller then you will not be able to access those controller. in that case you have to rethink about the design i mean whether you really need those controllers) if this one is the authorization problem then :before_filter is the best solution --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@... To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |