Class: Blogaze::Controllers::Admin::Users
- Inherits:
-
Controller
- Object
- Ramaze::Controller
- Controller
- Controller
- Blogaze::Controllers::Admin::Users
- Defined in:
- lib/blogaze/controllers/admin/users.rb
Instance Method Summary collapse
-
#delete(user_id) ⇒ Object
Delete user.
-
#edit(user_id) ⇒ Object
Edit user form.
-
#index ⇒ Object
Lists users.
-
#initialize ⇒ Users
constructor
A new instance of Users.
-
#save(user_id) ⇒ Object
Save user.
Methods inherited from Controller
#get_settings, #title, #view_file
Constructor Details
#initialize ⇒ Users
Returns a new instance of Users.
23 24 25 26 |
# File 'lib/blogaze/controllers/admin/users.rb', line 23 def initialize super title "Users" end |
Instance Method Details
#delete(user_id) ⇒ Object
Delete user
72 73 74 75 76 |
# File 'lib/blogaze/controllers/admin/users.rb', line 72 def delete(user_id) ::Blogaze::Models::User[user_id].delete flash[:success] = "User deleted successfully" redirect Users.r('/') end |
#edit(user_id) ⇒ Object
Edit user form
41 42 43 44 |
# File 'lib/blogaze/controllers/admin/users.rb', line 41 def edit(user_id) @user = ::Blogaze::Models::User[user_id] respond(view_file('admin/users/edit')) end |
#index ⇒ Object
Lists users
31 32 33 34 |
# File 'lib/blogaze/controllers/admin/users.rb', line 31 def index @users = ::Blogaze::Models::User.all respond(view_file('admin/users/index')) end |
#save(user_id) ⇒ Object
Save user
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/blogaze/controllers/admin/users.rb', line 51 def save(user_id) @user = ::Blogaze::Models::User[user_id] @user.username = request[:username] @user.email = request[:email] @user.group_id = request[:group_id] # Validate data if @user.valid? @user.save flash[:success] = "User saved successfully" redirect Users.r('/') end respond(view_file('admin/users/edit')) end |