On 1 December 2011 17:13, Craig White <[email protected]> wrote:
>
> On Dec 1, 2011, at 8:28 AM, Mauro wrote:
>
>> On 1 December 2011 00:54, Craig White <[email protected]> wrote:
>>>
>>> On Nov 30, 2011, at 3:31 PM, Mauro wrote:
>>>
>>>> I want to display different layouts based on user.
>>>> If user is "intraOp" the I want to use layout intraOp, if user is
>>>> "interOp" I want to display layout interOp while if controller_devise
>>>> I want to display application layout.
>>>> I based the user selection on request.path.
>>>> If request.path is /intraOp then I select user IntraOp, if /interOp
>>>> then select user interOp and so on.
>>>> The routes.rb is:
>>>>
>>>> match "intraOp" => "companies#index"
>>>> match "interOp" => "companies#index"
>>>>
>>>> The problem is that I use pagination.
>>>> When the request.path is /interOp companies#index is launched, and are
>>>> displayed 10 companies with pagination.
>>>> When I click for displaying page 2 companies#index is launched but the
>>>> path is not /interOp/companies......... but is
>>>> /intraOp/companies.........that is because companies#index is first
>>>> matched with "intraOp".
>>>> Have you some suggestions to solve the problem to having different
>>>> layouts based on user?
>>>> I prefer to not create two controllers: intraOp and interOp.
>>> ----
>>> stuff the 'company' into the users session and you can use the session 
>>> value everywhere, all the time (or not)
>>
>> Sorry for my ignorance, can you explain better?
> ----
> when the user logs in, set a session variable...
> session[:company] = @user.company
> and whenever you need to build a url with the company, include the 
> session[:company] in the url or if universal, you can probably add it to your 
> routes.

I don't know who the user is until it connect to the application.
I use devise.
If the user is signed_in the I want "application" layout and he can
create/modify/destroy.
If the user is not signed in then I must distinguish if to use "intra"
layout or "inter" layout.
To do this I am thinking to set a session variable called, for
example, session[:intra] or session[:inter].
The choice If to use session[:intra][ or session[:inter] is done looking at url.
If localhost/intra then I use "intra" layout and set session[:intra],
if localhost/inter I use "inter" layout and set session[:inter].
What do you think about?

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

Reply via email to