Varsha
Varsha

Reputation: 7

Structuring my website with Ruby on Rails

I am new to Ruby on Rails. I am trying to develop a website which has the structure as explained below. I have 2 tables (say A and B).A has many B.I have models and controllers for these tables(say A_m,A_c and B_m,B_c). My aim is to have different contorllers and views, for users and administrators. So I have another controller (say X_c).

Will I be able to fetch data into X_C and its associated views from the 2 tables( 2 models)? Or is this structure completely wrong? What materials can I refer to, to be able to acheive this?

Upvotes: 0

Views: 67

Answers (2)

jefflunt
jefflunt

Reputation: 33954

You don't need separate controllers for admins and users. You just need to lock down access to certain actions via some authorization mechanism. This site has a list of popular authorization tools that can help you do this.

Upvotes: 0

Artem Kalinchuk
Artem Kalinchuk

Reputation: 6652

You can fetch data from A_m or B_m in the X_C controller. Here is an example:

class XController < ApplicationController
    users = AModel.all
    other_table_data = BModel.where("field = 'value'")
end

All the models can accessed from any controller.

Upvotes: 0

Related Questions