Seperation of application specific view/controller code from


#1

[I posted to Rails Engines Forum but didn’t get a response so I am posting here]

I installed both login and user engines and got them working. Thanks for
an excellent job! Now, I have some questions on how to customize them
without breaking the code or making future upgrades messy. I have
several questions and any help will be greatly appreciated. I am
designing a student registration app for a community college.

First the view stuff. I’d like the signup/login/logout/change password
to be available via a sidebar. Basically I am trying to make this app
feel like a desktop all using Ajax.

I would like to have a lot more fields in the user table for the user
(student) profile and preferably I’d like to put the edit form right in
the side bar using an Ajax call. I currently have my cart for courses
chosen in the side bar and I’d like the whole login system to work in a
similar fashion. For example can I make a link_to_remote Ajax call to
:controller => user :action => signup and have it replace a div inside
my sidebar? How would I create a partial for that? If the rhtml files
are in my app/views will the engine know how to find it or is there a
configuration option for it?

Next the controller stuff, it says in the UserController to overide the
home action. I’d like the home to be Catalog/welcome. How do I overide
this?

With regard to the user_engine, I’d like students to be able to self
register and access their own records (both profiles and course
selections). The college staff can access ALL registrations and also the
courses database. So the admin creates staff users with these
permissions. I don’t need the guest role and the user role. Admin will
define a student role for the self registration. Can I delete the
default user and guest roles? How do I make registering students
automatically be assigned this role?

Thank you in advance,

bakki kudva


#2

Hi Bakki, apologies for the delay, lots of work on…

On 1/24/06, Bakki K. removed_email_address@domain.invalid wrote:

First the view stuff. I’d like the signup/login/logout/change password
to be available via a sidebar. Basically I am trying to make this app
feel like a desktop all using Ajax … and preferably I’d like to put the edit form right in
the side bar using an Ajax call. I currently have my cart for courses
chosen in the side bar and I’d like the whole login system to work in a
similar fashion. For example can I make a link_to_remote Ajax call to
:controller => user :action => signup and have it replace a div inside
my sidebar? How would I create a partial for that? If the rhtml files
are in my app/views will the engine know how to find it or is there a
configuration option for it?

You can create whatever partials you like in your own application. If
they are present in your /app/views folder they will be used in
preference of any engine views. To make these new forms work via AJAX,
you’ll need to create your own controller (possibly simply another
UserController) to handle the data being sent by by the AJAX
components and send back appropriate responses. This is going to be a
few hours of work at least, there’s no switch you can flip to turn
either of the engines into a AJAX machine…

I would like to have a lot more fields in the user table for the user
(student) profile

You can add any fields you like to the database, it won’t break the
system.

Next the controller stuff, it says in the UserController to overide the
home action. I’d like the home to be Catalog/welcome. How do I overide
this?

An upcoming release of the LoginEngine will provide this as a straight
option. You can use the current release branch -
http://opensvn.csie.org/rails_engines/login_engine/branches/rb_1.0

I don’t need the guest role and the user role. Can I delete the
default user and guest roles?

Be careful deleting roles that the UserEngine expects to find. The
Guest role is implicit for any useres who aren’t logged in, and
removing this cause the UserEngine to complain at startup. The User
role is the role automatically assigned to new users, so you might
consider making this the base set of permissions for every user.

With regard to the user_engine, I’d like students to be able to self
register and access their own records (both profiles and course
selections). The college staff can access ALL registrations and also the
courses database. So the admin creates staff users with these
permissions.

The key here is understanding that the UserEngine only restricts
access to particular actions. Therefore if you only want a particular
set of users to be able to manipulate a specific set of data, you need
to provide a set of controllers/actions for manipulating that subset
of data (for example, the currently-logged-in user’s own data), and
provide another set of controllers or actions for your
admin/super-users to work with all the data.

Admin will define a student role for the self registration. How do I make registering students
automatically be assigned this role?

By all means rename the User role to Student - there are config
options which do this when you’re running bootstrap. However, you
might also find it makes sense to have a special action which creates
users with the specific set of Roles that your application requires
(remember, users can have MANY roles…)

I hope this helps, sorry I don’t have time at the moment to give more
detailed answers…

  • james

#3

Hi James,

Thank you very much for taking time from your busy schedule to elaborate
answers to my questions. I very much appreciate it. It helped me a lot
to
understand how I might have to architect my app.

-bakki