SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Easiest Way to Have Class in Rails

    Hi,

    I'm new to both ruby and rails (coming from an experienced background in PHP) and I am attempting to create a webapp with rails. I need to have a user class manage users by authenticating, creating, updating, etc. and this class will be used on many pages/controllers with rails.

    Where would be the best place to store this class file? What would be the best way to include it within a page? How can I allow the class to use other Rails classes (activerecord)?

    Thanks,
    Mitch

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Are you just doing a session-based login? If so then this might help speed things along

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia
    Are you just doing a session-based login? If so then this might help speed things along
    Oh that looks very good thank you

  4. #4
    SitePoint Addict SRTech's Avatar
    Join Date
    Mar 2005
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you need an easy way for people to signup and manage their own accounts, you might look at:
    http://wiki.rubyonrails.com/rails/pa...LoginGenerator

    Just a little more advanced (and supposed to be more secure) than the LoginGenerator

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again.

    I also realized to add my own "global" classes I can edit application.rb I'm learning... and its looking great!

  6. #6
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by xmitchx
    Thanks again.

    I also realized to add my own "global" classes I can edit application.rb I'm learning... and its looking great!
    You can add your own models into the app/models directory (they don't need to be ActiveRecord models) and then use them like this:

    Code:
    class ApplicationController < ActionController::Base
        model :my_global_class
    end
    Documentation here: http://api.rubyonrails.com/classes/A...ssMethods.html

    Douglas
    Hello World


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •