I have a devise model called admin which gives me current_admin and
the model has a method called role, which is either 'free' or
'standard' or 'premium'.

I have a dashboard_controller with three actions:

def index ... end
def free ... end
def premium ... end

I have a passthrough_controller that handles which dashboard action an
admin should be redirected to based on their role:

class PassthroughController < ApplicationController
def index
path = case current_admin.role
when 'free'
dashboard_free_path
when 'standard'
dashboard_standard_path
when 'premium'
dashboard_premium_path
else
admin_signin_path
end

redirect_to path
end
end

And I have these routes set up:

devise_for :admins do
match "/admins/sign_out" => "devise/sessions#destroy"
match "/dashboard/index" => 'passthrough#index'
match "/dashboard/free" => 'dashboard#free', :as
=> :dashboard_free_path
match "/dashboard/standard" => 'dashboard#standard', :as
=> :dashboard_standard_path
match "/dashboard/premium" => 'dashboard#premium', :as
=> :dashboard_premium_path
end

This isn't working, but I'd like to know why it isn't working and
where I'm going wrong.

Thanks

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Ryan Cheung at Feb 23, 2012 at 12:44 pm
    Try to use 'rake routes' command to figure out the valid routes currently
    you have. If any valid routes was added to the routes.rb file, you'll see
    it.
    --
    Best Regards,
    Ryan Cheung


    On Thu, Feb 23, 2012 at 5:53 PM, simpleton wrote:

    I have a devise model called admin which gives me current_admin and
    the model has a method called role, which is either 'free' or
    'standard' or 'premium'.

    I have a dashboard_controller with three actions:

    def index ... end
    def free ... end
    def premium ... end

    I have a passthrough_controller that handles which dashboard action an
    admin should be redirected to based on their role:

    class PassthroughController < ApplicationController
    def index
    path = case current_admin.role
    when 'free'
    dashboard_free_path
    when 'standard'
    dashboard_standard_path
    when 'premium'
    dashboard_premium_path
    else
    admin_signin_path
    end

    redirect_to path
    end
    end

    And I have these routes set up:

    devise_for :admins do
    match "/admins/sign_out" => "devise/sessions#destroy"
    match "/dashboard/index" => 'passthrough#index'
    match "/dashboard/free" => 'dashboard#free', :as
    => :dashboard_free_path
    match "/dashboard/standard" => 'dashboard#standard', :as
    => :dashboard_standard_path
    match "/dashboard/premium" => 'dashboard#premium', :as
    => :dashboard_premium_path
    end

    This isn't working, but I'd like to know why it isn't working and
    where I'm going wrong.

    Thanks

    --
    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@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/rubyonrails-talk?hl=en.
    --
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Simpleton at Feb 23, 2012 at 12:55 pm
    Hi Ryan

    I've solved this. I had to remove the matched routes from the
    devise_for block and I had a get '/dashboard/index' on top of my
    routes file.

    Thanks

    --
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 23, '12 at 9:53a
activeFeb 23, '12 at 12:55p
posts3
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Simpleton: 2 posts Ryan Cheung: 1 post

People

Translate

site design / logo © 2022 Grokbase