Hi all,
I’d like to write an ldap application using rails, but not 100% sure how
to lay everything out.
there are no models, as the data is all stored in ldap, so would
everything be done in just the views and controllers?
i’ve previously written an ldap connection app and i had the connection
class in lib/ldap_con.rb .
i had “$sessions = {}” in environment.rb, so when a controller created a
new connection_object, i stored the session object in that hash - is
that the right way to do it??
the problem with that was every action in my controllers would need to
create a new session variable and grab the session, which didn’t seem
right to me.
ie each method had:
@session = $sessions[session.session_id]
another problem with this is that the ldap_con.rb file had everything in
it - all the modify/create/delete methods, as well as connection and
disconnection methods.
any thoughts on how to go about this?
thanks for reading.
Hi
Paul PH wrote:
Hi all,
I’d like to write an ldap application using rails, but not 100% sure how
to lay everything out.
there are no models, as the data is all stored in ldap, so would
everything be done in just the views and controllers?
Just because you aren’t persisting your data with ActiveRecord doesn’t
mean that you shouldn’t have models. All of your business logic should
be in your models. Your controllers should only load enough data for
your view to present.
bryanl wrote:
Hi
Paul PH wrote:
Hi all,
I’d like to write an ldap application using rails, but not 100% sure how
to lay everything out.
there are no models, as the data is all stored in ldap, so would
everything be done in just the views and controllers?
Just because you aren’t persisting your data with ActiveRecord doesn’t
mean that you shouldn’t have models. All of your business logic should
be in your models. Your controllers should only load enough data for
your view to present.
are there any examples out there of how to do this? i’ve no idea how to
write a model that doesn’t depend on a postgres backend of some sort, so
i’m pretty stuck.
regarding the session, is a global session hash the right way to store
and access it?
thanks for the reply.
Hi
are there any examples out there of how to do this? i’ve no idea how to
write a model that doesn’t depend on a postgres backend of some sort, so
i’m pretty stuck.
regarding the session, is a global session hash the right way to store
and access it?
thanks for the reply.
A simple example on how to start this: Parked at Loopia
You could create a base class called LdapModels and have your models
inherit from that so you could share some of the code for accessing
LDAP.
Paul PH wrote:
bryanl wrote:
Hi
are there any examples out there of how to do this? i’ve no idea how to
write a model that doesn’t depend on a postgres backend of some sort, so
i’m pretty stuck.
Also, take a look at ActiveLDAP -
http://wiki.rubyonrails.com/rails/pages/ActiveLDAP
bryanl wrote:
Hi
are there any examples out there of how to do this? i’ve no idea how to
write a model that doesn’t depend on a postgres backend of some sort, so
i’m pretty stuck.
regarding the session, is a global session hash the right way to store
and access it?
thanks for the reply.
A simple example on how to start this: Parked at Loopia
You could create a base class called LdapModels and have your models
inherit from that so you could share some of the code for accessing
LDAP.
thanks for the example. i’ve had a go at doing something like that, but
not got too far.
I don’t know where to ‘require…’ my lib/ where to < Inherit it, or
anything.
thanks again for the reply, but i think i’m going to give up on this one
rather than pull more hair out.
either i’ve not read the agile web development and ruby for rails books
thoroughly enough, or rails just seems to be all about database apps,
and since i’m not using one it’s just too difficult.
cheers.
Benjamin Ritcey wrote:
Paul PH wrote:
bryanl wrote:
Hi
are there any examples out there of how to do this? i’ve no idea how to
write a model that doesn’t depend on a postgres backend of some sort, so
i’m pretty stuck.
Also, take a look at ActiveLDAP -
Peak Obsession
i’ve looked at activeldap a little, and that seems even more confusing
to me.
i’ve made a little bit of progress going about using my own models
though.
i have my controller creating a new instance of the model, and the model
accesses the ldap_connection.rb lib methods by require
‘ldap_connection.rb’.
what STILL baffles me though, is the separation between the model and
the lib. if i have a search_for_user(name) method in my controller, i
also need a search_for_user(name) method in the lib. i don’t understand
that at all.
thanks.
Paul PH wrote:
the lib. if i have a search_for_user(name) method in my controller, i
also need a search_for_user(name) method in the lib. i don’t understand
that at all.
thanks.
Right - ActiveRecord (and ActiveLDAP, to a degree) hides all that away -
if you’re not going to use them, you’ll need to implement all of those
functions yourself.